for faceTracking, high resolution video is low performance. so usually using low resolution image. right?
but I want to display high resolution image, with fast facetracking.
so I tried this way…
- get pixels from cam
- drawing in FBO in half size
- readPixels from FBO to half size ofImage,
- facetracning with resized ofImage.
but I got runtime error…
OpenCV Error:Assertion failed (size.area()>0) in resize
OpenCV Error: Assertion failed (ssize.area() > 0) in resize, file /Users/danielrosser/Documents/openFrameworks/scripts/apothecary/build/opencv/modules/imgproc/src/imgwarp.cpp, line 1834
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/danielrosser/Documents/openFrameworks/scripts/apothecary/build/opencv/modules/imgproc/src/imgwarp.cpp:1834: error: (-215) ssize.area() > 0 in function resize
I thought it’s because use ofImage. so I tried another ofImage camImg… and get pixels from cam(ofVideoGrabber).
and it works…
I’m wondering what is the problem? as error let me know it related with cv.resize… but I didn’t get it.
cv::resize(gray,small_img_,cv::Size(w,h),0,0,CV_INTER_LINEAR); <-Thread 1 : signal SIGABRT
anyone help? or other solution for that?
here’s my code… and you can get my Xcode project from here.
before you need to download ofxFaceTracker addon.
#include "ofApp.h"
using namespace ofxCv;
void ofApp::setup() {
camWidth = 1280;
camHeight = 800;
cam.initGrabber(camWidth, camHeight);
tracker.setup();
camImg.allocate(camWidth, camHeight, OF_IMAGE_COLOR); // ofImage camImg - full size (for testing)
copiedImg.allocate(camWidth/2, camHeight/2, OF_IMAGE_COLOR); // ofImage copiedImg - half size
fbo.allocate(camWidth/2, camHeight/2); // ofFbo fbo - half size
}
void ofApp::update() {
ofSetWindowTitle(ofToString(ofGetFrameRate()));
cam.update();
if(cam.isFrameNew()) {
camImg = cam.getPixels(); // dump cam -> camImg
// fill FBO
fbo.begin();
cam.draw(0, 0, camWidth/2, camHeight/2); // draw half size
fbo.end();
fbo.readToPixels(pix);
copiedImg.setFromPixels(pix);
copiedImg.update(); // need to this ??
// tracker.update(toCv(cam)); // tracking with ofVideoGrabber.. work.
// tracker.update(toCv(camImg)); // tracking with ofImage.. work.
tracker.update(toCv(copiedImg)); // OpenCV Error: Assertion failed (ssize.area() > 0) in resize,
}
}
void ofApp::draw() {
ofSetColor(255);
cam.draw(0, 0);
ofSetLineWidth(2);
tracker.draw();
ofPolyline noseBase = tracker.getImageFeature(ofxFaceTracker::NOSE_BASE);
ofSetColor(ofColor::red);
noseBase.draw();
ofDrawCircle(noseBase.getCentroid2D(), 8 * tracker.getScale());
ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20);
}
void ofApp::keyPressed(int key) {
if(key == 'r') {
tracker.reset();
}
}