ofxCv with ofxARKit?

Hi all! I’m working with ofxARKit and I’m running into an issue when using ofxCv. I want to take ofxCv’s contour and overlay it ontop of ofxARKit’s viewport window.

To do so, I am using ofxARKit’s face-tracking-example, and I’ve included ofxCv in efforts to overlay the polyline on top of ARKit’s viewport.

cam.setDeviceID(1);
cam.setup(640, 360);

Above is the code for my ofVideoGrabber, within my setup(). When I comment those lines out, I am able to see my front-camera display, coming from ofxARKit. When they’re uncommented, and I perform my contourFinder thresholding, I am presented with a black screen and my contour drawn on top.

Is there anyway where I can use ofxARkit’s camera display and ofxCv’s video grabber at the same time?

warning] ofVideoGrabber: setPixelFormat(): can't set pixel format while grabber is running
2019-12-07 15:12:26.932060-0700 example-face-tracking[9308:1729614] [Session] Session (0x121d1d8b0): did fail with error: Error Domain=com.apple.arkit.error Code=102 "Required sensor failed." UserInfo={NSLocalizedFailureReason=A sensor failed to deliver the required input., NSUnderlyingError=0x283d150e0 {Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-12780), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x283d14f90 {Error Domain=NSOSStatusErrorDomain Code=-12780 "(null)"}}}, NSLocalizedRecoverySuggestion=Make sure that the application has the required privacy settings., NSLocalizedDescription=Required sensor failed.}
2019-12-07 15:12:26.933091-0700 example-face-tracking[9308:1729614] [Session] Session (0x121d1d8b0): did fail with error: Error Domain=com.apple.arkit.error Code=102 "Required sensor failed." UserInfo={NSLocalizedFailureReason=A sensor failed to deliver the required input., NSUnderlyingError=0x283d15a70 {Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-12780), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x283d15c20 {Error Domain=NSOSStatusErrorDomain Code=-12780 "(null)"}}}, NSLocalizedRecoverySuggestion=Make sure that the application has the required privacy settings., NSLocalizedDescription=Required sensor failed.}

When I have setup and allocated my ofVideoGrabber I receive the two errors and one warning, seen above

I guess the most simple way of solving this is how would I be able to perform CV’s thresholding on my video input coming from ofxARKit? ofVideoGrabber is providing some complications, and I am unsure of what is the video input source of an ofxARKit application. Is that what the ARRef processor; object is for? Is there a way for me to retrieve the processor width and height so I can push it through CV’s allocation functions?

I’ve been meaning to try this for a while so following this thread.

(Will try it nevertheless too and see what I get)

Quickly - draw arkit video into an fbo, read fbo to ofpixels, pass ofpixels to opencv. The read back is slow so you might want to scale it down to 1/2 or 1/4 screen res.

2 Likes

Zach thank you so much! This solution works perfectly, @ayruos