This code initializes two video threads for infrared and visible light video acquisition using 'promise' and 'future' objects. It first creates two 'promise' objects for the IR and VIS frames and gets corresponding 'futures'. Then it creates two threads for IR and VIS frame acquisition using these 'promise' objects. The IR and VIS threads are detached, and the current frames are obtained from the 'futures'. If the frames are not empty, they are displayed.

The 'video_IR_frame_acquisition' function initializes the IR camera by opening the video capture object and checking if it is opened successfully. It then reads and processes the frames from the IR camera, converts them to grayscale, and calculates the difference between the current and previous frames. The frames are then stored as the previous frames for the next iteration.

The 'video_VIS_frame_acquisition' function initializes the visible light camera similarly to the IR camera. It reads and processes the frames from the VIS camera, converts them to grayscale, and calculates the difference between the current and previous frames. The difference frame is then passed to the 'promise' object using 'set_value', which is used to pass the result to the main thread.

Overall, the code initializes two video threads for IR and VIS frame acquisition using 'promise' and 'future' objects and calculates the difference between consecutive frames.

C++ 多线程视频采集:使用 Promise 和 Future 实现红外和可见光帧差异计算

原文地址: https://www.cveoy.top/t/topic/odBW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录