imencode exception in second thread [closed]

asked 2015-02-11 10:43:51 -0600

borjaevo gravatar image

updated 2015-10-06 08:45:25 -0600


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.


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-09-27 09:04:42.406683


it is already suspicious, that you never mention the word 'lock'. ;)

berak gravatar imageberak ( 2015-02-11 10:49:30 -0600 )edit

I' dont write any shared object. But, can you explain a little more about what are you suspecting?

borjaevo gravatar imageborjaevo ( 2015-02-11 10:53:11 -0600 )edit

where does the image come from ? webcam ?

berak gravatar imageberak ( 2015-02-11 10:54:55 -0600 )edit

Yes, it come from Kinect but i have two modes of working, multithreading and only one. With one thread works great.

borjaevo gravatar imageborjaevo ( 2015-02-11 11:04:55 -0600 )edit

"I' dont write any shared object. " - well, you definitely do so in this case

berak gravatar imageberak ( 2015-02-11 11:08:21 -0600 )edit

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

borjaevo gravatar imageborjaevo ( 2015-02-11 11:37:45 -0600 )edit