kylemcdonald / ofxCv

Alternative approach to interfacing with OpenCv from openFrameworks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'opencv2/opencv.hpp' file not found

mikevanis opened this issue · comments

Hi! I downloaded ofxCv as described in the README (cloned repo into addons). I then built a new project with the of projectGenerator and initially just wanted to test that everything is up and running. Therefore, my ofApp just opens an ofVideoGrabber and tries to draw the output. When I try to run, I get the following compilation error: 'opencv2/opencv.hpp' file not found. This seems to root down to ofxCv.h located in addons/ofxCv/src/ofxCv.h.

Any help would be greatly appreciated!

EDIT: this is on Xcode 7.0.1.

Here is my ofApp.h:

#pragma once

#include "ofMain.h"
#include "ofxCv.h"

class ofApp : public ofBaseApp{
public:
    void setup();
    void update();
    void draw();

    ofVideoGrabber cam;
    //cv::Mat empty;
};

Here is my ofApp.cpp:

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
    cam.initGrabber(320, 240);
}

//--------------------------------------------------------------
void ofApp::update(){
    cam.update();
}

//--------------------------------------------------------------
void ofApp::draw(){
    cam.draw(0, 0);
}

Just drag and drop opencv2.framework in your project in XCode and you should be good to go.
Also, you might run into some linker errors as the project generator does not add the AssetsLibrary.framework to the project. To fix this, simple add the AssetsLibrary under the general tab for your XCode project.

this is a bug with the project generator. currently it's not processing addon dependencies openframeworks/projectGenerator#90

to make a working project, please manually add ofxOpenCv with the project generator.

i'll leave this issue open until openframeworks/projectGenerator#90 is merged and the next version of OF is released.

this is working for me now.

I already try all this, and still getting 'opencv2/opencv.hpp' file not found

@bboyslak please post more info.

  1. what operating system version?
  2. what version of OF?
  3. where did you put the ofxOpenCv folder?
  4. which example are you running?
  5. did you generate the project file with the project generator, or some other way?

Mac OS 10.10.5
oF 0.9.3
ofxOpenCv folder is in /addons
im trying to run CREA for oF 0.9 ( https://github.com/fabiaserra/crea/tree/OF0.9.0 )
app was already done by fabiaserra i just download everything and run, but the only error i get is 'opencv2/opencv.hpp' file not found

Same issue as you @bboyslak
screen shot 2016-05-18 at 8 27 57 am

However, I'm using OF0.8.4

commented

Same issue...

  1. OS X 10.10.5
  2. oF v 0.9.8
  3. Error occurs when creating the project through the project generator OR manually putting the ofxOpenCv in the addons folder in XCode project
  4. I'm running the graphics example (super basic ellipse) with the inclusion of #include "ofxCv.h" in ofApp.h file.
  5. unsuccessful with the project generator and with doing it manually.
  6. XCode 7.2.1

I found a quick (possibly dirty) solution to this. In the file throwing the error I deleted the "#include opencv2/opencv.hpp" line. Then copied the lines of code located in opencv.hpp and put them directly where the error was thrown. Since the opencv.hpp piece of code seems to mostly just be including other files, it works to just pass them in. The lines are:

#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/photo.hpp"
#include "opencv2/video.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/ml.hpp"

Seems to work for me now at least, can further clarify if it helps anyone. Thanks @kylemcdonald for the brilliant work!