hi guys~ i just write a simple project with OpenCV functions directly called. but i find i couldn’t exit the application successfully with hitting Esc. Could anybody figure out why?
p.s. i remember that once upon a time, CCV had this problem too. so is it because the direct use of OpenCv functions?
Here is the testApp.h
#ifndef _TEST_APP
#define _TEST_APP
#include "ofMain.h"
#include "ofxOpenCv.h"
#include "ofxDirList.h"
#include "ofxVectorMath.h"
#include "ofxNetwork.h"
#include "ofxOsc.h"
#include "ofxThread.h"
#include "ofxXmlSettings.h"
#include "ofx3DModelLoader.h"
#include "highgui.h"
class testApp : public ofBaseApp{
public:
testApp();
void setup();
void update();
void draw();
void keyPressed (int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void resized(int w, int h);
private:
CvCapture *cap;
IplImage * image, *grayImage;
int wid,hei;
int deviceID;
ofxCvGrayscaleImage ofcvGrayImage;
};
#endif
And here is the testApp.cpp
#include "testApp.h"
#include "stdio.h"
//--------------------------------------------------------------
testApp::testApp(){
}
//--------------------------------------------------------------
void testApp::setup(){
deviceID=0;
cap=cvCreateCameraCapture(deviceID);
image=cvQueryFrame(cap);
wid=image->width;
hei=image->height;
grayImage=cvCreateImage(cvSize(wid,hei),IPL_DEPTH_8U,1);
ofcvGrayImage.allocate(wid,hei);
}
//--------------------------------------------------------------
void testApp::update(){
image=cvQueryFrame(cap);
cvCvtColor(image,grayImage,CV_BGR2GRAY);
ofcvGrayImage.setFromPixels((unsigned char*)grayImage->imageData,wid,hei);
}
//--------------------------------------------------------------
void testApp::draw(){
ofcvGrayImage.draw(0,0);
}
//--------------------------------------------------------------
void testApp::keyPressed (int key){
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::resized(int w, int h){
}