Home > Back-end >  Thread, twice the while (true) circulation between caton problems
Thread, twice the while (true) circulation between caton problems

Time:11-19

In c + + handle camera image flow, the process is divided into three steps: 1, the image from the camera API (mat), 2, splicing restructuring images (need time online multiple pictures), 3, to save stitching good image output,
Use three threads respectively with three steps, data through the two list to interact,
The present question is that in the first thread, use the while (true) cycle from the camera to take pictures, detected twice while execution time is not stable, most of the time is less than 1 millisecond, and occasionally there will be more than 200 milliseconds, the condition of the thread is not into the loop in time, can't get the camera's image, and then lost frames and lead to image fails,
Now tried method are:
1, use the SetThreadPriority (t_s. Native_handle (), THREAD_PRIORITY_TIME_CRITICAL); Raise the priority of a thread 1 is invalid;
2, use the SetThreadAffinityMask (t_s. Native_handle (), 248); Assign thread 1 a single CPU cores (5/8), invalid.
3, thread 2 and 3 combined threads, using a thread, invalid
4, the above three methods used at the same time, invalid

Within the scope of the detection method can alleviate the phenomenon include:
1, artificial lower frame frequency, effective
2, do not open the thread 3, that is, not opening stock figure thread, effective,

Excuse me each great god, why can appear such circumstance, how to solve this problem?
Thank you,