So why don't you create it in the worker thread?
So why don't you create it in the worker thread?
Hi,
Reading the code again I have to say that it's not true that I'm not using the camera object into differetn threads. It's used on the main thread by a timer that every 500ms checks the camera inputs and also it's used into the "producer" thread to capture images and into the "consumer" thread to activate or deactivate some camera outputs.
I will try to disable the timer to check inputs and also move the capturing process into the "consumer" thread to use only one thread.
Really don't know how to open the camera there without doint on the run method. I want to mantain the camera opened when the thread is not running. I can't use QObject::moveToThread because the camera object does not inherit from QObject.So why don't you create it in the worker thread?
Thanks,
Òscar Llarch i Galán
Hi,
Finally I found on new documentation that the camera object must not be shared between threads(and what if I have the old one?!!). In this moment it's not shared as it is only used on the worker thread but it still belong to the main thread. There are two examples of the library, first one creates the camera object on the worker thread and the second one creates the camera object on the CDialog(the examples are MFC, not Qt) and uses it into the worker thread. This second example uses the same way as I'm using. Now I remember another example that they provide that use the worker thread to paint images into the display and when I told them that it was not possible they said that it was a bad example
So, thanks for your responses but in this moment I need to ask to library providers support about this problem. Monday will try to use this second version that creates the object on the main thread and usues it on the worker thread to see if it works.
Thanks,
Òscar Llarch i Galán
I think it is enough if you simply protect your camera with a mutex.
^NyAw^ (26th May 2013)
Bookmarks