imencode exception in second thread [closed]
Hello,
I'm having problems encoding an image to jpg in a second thread. It's doing well in main thread but got an exception again and again when i try from other thread.
So, i have a Mat object called A in main thread and have a struct containing A and other variables that i passed to new thread as a parameter. I think this part is well because i can view Mat A object in new thread with debugger and has the correct size. After that, i do the encoding and got the exception, i don't have very much info about the exception:
code: 0xe06d7363 flags=0x1 (execution cannot be continued)
and in funtion levels
0 level: RaiseException -> File: KernelBase
1level: CxxThrowException -> File: MSVCR120
2level: cv::error -> File:opencv_core249
3level: cvWaitKey -> File:opencv_highgui249
4level: cv::imencode -> File:highgui249
I'm very lost so any help i really appreciate.
Thanks
it is already suspicious, that you never mention the word 'lock'. ;)
I' dont write any shared object. But, can you explain a little more about what are you suspecting?
where does the image come from ? webcam ?
Yes, it come from Kinect but i have two modes of working, multithreading and only one. With one thread works great.
"I' dont write any shared object. " - well, you definitely do so in this case
OK, supposing you're right i make a clone of mat object before is passed to second thread and yes, it seems to work better so i think you're right. Now i have an arbitrary fault. Sometimes happed in first iteration, others keep working 100 or more iterations. The error is Raw image encoder error: empty jpeg image (DNL not supported) in cv::BaseImageEncoder::throwOnError Thank you