bakercp / ofxIpVideoGrabber

An openFrameworks addon for MJPEG streams (Axis IP Camera, mjpeg-streamer, etc.).
MIT License
104 stars 28 forks source link

use in separate thread #13

Closed antimodular closed 8 years ago

antimodular commented 9 years ago

hello again.

with the old version for of 0.8.4 i was able to change your addon to also work inside a thread other than the main one. basically did this in multiple locations

if(bUseInThread) img->setUseTexture(false);

but your new addon does this

img = std::make_shared<ofImage>();

which i think ignore my setUseTexture call.

do you think there is a way to have this run in a separate thread?

antimodular commented 9 years ago

ok. taking out the following line made it work.

img = std::make_shared<ofImage>();

but i am not sure how stable it will be. what do you think?

bakercp commented 9 years ago

You should be able to just call IPVideoGrabber::setUseTexture() on your instance to disable texture use for non-main-thread use.

antimodular commented 9 years ago

thanks. just tried

    ipCamGrabber = std::make_shared<Video::IPVideoGrabber>();
    ipCamGrabber->setUseTexture(false);

    ipCamGrabber->setUsername(cam_user);
    ipCamGrabber->setPassword(cam_password);

but it prints out

[ error ] IPVideoGrabber: update() may not be called from outside the main thread.

because your addon checks

if(!isMainThread())
bakercp commented 9 years ago

Aha. That's something that would be pretty easy to fix.

antimodular commented 9 years ago

great. i tried by commenting out code some code and it did make it work inside a separate thread. but the video got pretty slow.

bakercp commented 8 years ago

Removed if (!isMainThread()) because it is not longer part of ofThread.