Mariusmssj4
Posts: 15
Joined: Thu Jan 23, 2014 10:37 am

libopencv-dev missing functions and members

Wed Jan 29, 2014 4:32 pm

Hi,

I am working on getting some OpenCv code working on the Pi.

I got OpenCV installed using

Code: Select all

sudo apt-get install libopencv-dev
and using RaspiCam: C++ API for using Raspberry camera

the code I am using is quite simple :

Code: Select all

#include <ctime>
#include <iostream>
#include <raspicam/raspicam_cv.h>

using namespace std; 

int main(int argc,char **argv)
{
	//Load Image//////////////////////////////
	
	cv::Mat img = cv::imread("../raspicam_cv_image.jpg");

	cv::Mat element = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(5, 5));
	
	cv::erode(img, img, element);
	
    //save image 
    cv::imwrite("../tested.jpg", img);
    cout<<"Image saved at tested.jpg"<<endl;
}
using :

Code: Select all

 g++ opencv_test.cpp -o  opencv_test -I/usr/local/include/ -lraspicam -lraspicam_cv -lmmal -lmmal_core -lmmal_util -lopencv_core -lopencv_highgui 
but I keep getting these errors:

Code: Select all

open_test.cpp: In function  int main(int ,char **):
open_test.cpp: 14:20: error: getStructuringElement is not a member of cv
open_test.cpp: 14:46: error: MORPH_RECT is not a member of cv
open_test.cpp: 16:2: error: erode is not a member of cv
 
Not sure what's wrong, any ideas?

Mariusmssj4
Posts: 15
Joined: Thu Jan 23, 2014 10:37 am

Re: libopencv-dev missing functions and members

Fri Jan 31, 2014 9:53 am

Fixed it :)

needed to add

Code: Select all

#include "opencv2/imgproc/imgproc.hpp"
to my .cpp file

and

Code: Select all

-lopencv_imgporc
to the g++ command

Return to “C/C++”