dmroeder
Lifetime Supporting Member
I did a project a few years ago where I had to keep a buffer of video, say from IP cameras, in order to get video clips of a machine when it fault. The basic idea was few IP cameras were placed on the machine, a piece of software captured the video and kept a buffer from each camera, when I detected a machine fault, I told the software to encode the buffer and save the video clip.
My original solution wasn’t ideal. The software keeping the video buffer was a CPU pig and the machine it was running on wasn’t very powerful. I had to write a program that interfaced with the camera software and the PLC. I have enough experience with interfacing with the PLC, but having to interface with another piece of software made it a bit of a pain since I had no control of whether the software was doing what it was supposed to be doing.
Anyway, I recently rewrote it using OpenCV and python to capture the video buffer, which means I can control all of it. OpenCV handles the cameras better, I can keep the frames in memory, which ends requiring much less CPU. I put it up on github.
At a basic level, you define your cameras in the config file (local USB cameras or IP cameras), point it to a BOOL tag that goes true when there is a fault, the buffer of video from all configured cameras will be saved in MP4 format. You can configure whether you want to write the fault tag back to 0 or not, the max number of clips you want to keep on disk for each camera, as well as the number of seconds of video you want to keep.
If you’re interested:
https://github.com/dmroeder/fault_video
My original solution wasn’t ideal. The software keeping the video buffer was a CPU pig and the machine it was running on wasn’t very powerful. I had to write a program that interfaced with the camera software and the PLC. I have enough experience with interfacing with the PLC, but having to interface with another piece of software made it a bit of a pain since I had no control of whether the software was doing what it was supposed to be doing.
Anyway, I recently rewrote it using OpenCV and python to capture the video buffer, which means I can control all of it. OpenCV handles the cameras better, I can keep the frames in memory, which ends requiring much less CPU. I put it up on github.
At a basic level, you define your cameras in the config file (local USB cameras or IP cameras), point it to a BOOL tag that goes true when there is a fault, the buffer of video from all configured cameras will be saved in MP4 format. You can configure whether you want to write the fault tag back to 0 or not, the max number of clips you want to keep on disk for each camera, as well as the number of seconds of video you want to keep.
If you’re interested:
https://github.com/dmroeder/fault_video