Having some trouble getting a basic threaded video grabber working as per the example on the ofThread page in the docs. The following compiles but then quits out with a “BAD_EXC_ACCESS” message as soon as it runs. Would very much appreciate some pointers as to where I’m going wrong.
I’m not sure but important to know is are you setting your image to draw by value or by reference? In your thread code you set from pixelsRef. I don’t know what setfrompixels does exactly but if you are setting by reference in update by the time you get to draw it might be gone already… but again I don’t know by heart. Can you tell where you get the BAD ACCESS exactly?
However, even if I take EVERYTHING out and try to just simply instantiate an ofVideoGrabber in the thread, as soon as I add a call to update() or grabFrame() in the threadedFunction it still does the same thing. Same result if the call is inside the lock() or not. I’ve also tried setting setUseTextures to false to remove anything GL related, but still no dice.
This leaves me pretty stuck…can anyone shed any light on this?
Think I might have cracked it. I wasn’t initiating the grabber properly; although I was calling setUseTextures, I think I was then screwing that up by not including a false value after w and h for initGrabber. In fact the latter is all you need to do.
With regard the reference issue, I couldn’t get the setup outlined on the ofThread docs page to work with ofImage, so I did something a little different with ofPixels. This all seems to be working…I think!
Because OpenGL functions can only be called from the thread where the context was created, in this case the window. Thus, it is not possible to do things like uploading a texture to the graphics card in other threads. @MatthiasEsterl has the correct technique.
For another example see this addon https://github.com/bakercp/ofxIpVideoGrabber which connects to an ip video source in one thread, sets the pixels, but only uploads the pixels to the graphics card in the main loop (i.e. when update() is called).
i just tried the ofxDocuApp and works great. But i am struggling to create multiple instances of it. I am trying to get multiple video cams grabbing each in their own thread.
has this worked for you?
i get crash notices at different places after the app starts.
Could you provide a little bit more insight into your issue (code, errors)?
I’ve never tried to hock up more than one camera, but from my understanding, it should work.