Juce automatically closing camera? (OpenCV, Mac)


#1

Hello! I’m making a Juce plugin using opencv, and am running into an interesting issue. For some reason, I am unable to keep the camera on for multiple iterations of the draw loop in the Editor.cpp file.

I’m currently opening the camera with opencv (VideoCapture cap(1);) in the ProcessorEditor constructor. (cap is a private variable of the ProcessorEditor.) However, by the time the program first enters into the draw function, the camera is no longer open. I know this by using this at the beginning of each draw loop:

if(!cap.isOpened()){...

This if loop triggers the first time draw is called. Even if I then open the camera after that if statement, so that if it wasn’t previously opened it would be then, the if loop is still triggered on the next pass through the draw function.

I’m wondering if there is something about the draw loop in Juce that could kill the capture object or automatically close the camera or something like that.

Thanks!


#2

Seems unlikely - most probably you’re deleting the camera object accidentally!