Community
cancel
Showing results for 
Search instead for 
Did you mean: 
PPoob
New Contributor I
1,169 Views

how to compile opencv using g++ for intel edison

hi i am currently doing a project that requires both mraa and opencv, my question is how do i compile a program using g++

for example for just using mraa the g++ compile looks something like this : g++ -lmraa -o sample sample.cpp

so how do i complie with mraa and opencv, i have been gettting all kinds of errors compiling.

p.s i have installed opencv in my intel edison by following this tutorial : https://software.intel.com/en-us/articles/opencv-300-ipp-tbb-enabled-on-yocto-with-intel-edison https://software.intel.com/en-us/articles/opencv-300-ipp-tbb-enabled-on-yocto-with-intel-edison

7 Replies
idata
Community Manager
94 Views

Hi Prashanth93,

Could you please copy and paste here the command that you're using to compile the openCV program and the output that you're getting? It might be an issue with a library, like this case: /thread/75235 https://communities.intel.com/thread/75235, where a library was missing at the time of compilation, so the simplest solution was to remove the aforementioned library. Check out the thread and let us know if that helps, also remember to share the command and the output.

Regards,

 

Pablo
PPoob
New Contributor I
94 Views

------------------------ this is the error message im getting------------------------------------------------------------------------------

/tmp/ccDQvlDL.o: In function `cv::Mat::~Mat()':

camread.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x2f): undefined reference to `cv::fastFree(void*)'

/tmp/ccDQvlDL.o: In function `cv::Mat::create(int, int, int)':

camread.cpp:(.text._ZN2cv3Mat6createEiii[_ZN2cv3Mat6createEiii]+0x6e): undefined reference to `cv::Mat::create(int, int const*, int)'

/tmp/ccDQvlDL.o: In function `cv::Mat::release()':

camread.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x38): undefined reference to `cv::Mat::deallocate()'

collect2: error: ld returned 1 exit status

-------------------------------------------------------------------------------------------------------------------------------------------------------------

-----------------------this is the code im trying to compile---------------------------------------------------------------------------------

# include

# include

# include

# include

# include

using namespace std;

using namespace cv;

int main(){

mraa_init();

mraa_gpio_context d0;

mraa_gpio_context d1;

mraa_gpio_context d2;

mraa_gpio_context d3;

mraa_gpio_context d4;

mraa_gpio_context d5;

mraa_gpio_context d6;

mraa_gpio_context d7;

mraa_gpio_context vsync;

mraa_gpio_context href;

mraa_gpio_context pclk;

d0 = mraa_gpio_init(2);

d1 = mraa_gpio_init(3);

d2 = mraa_gpio_init(4);

d3 = mraa_gpio_init(5);

d4 = mraa_gpio_init(6);

d5 = mraa_gpio_init(7);

d6 = mraa_gpio_init(8);

d7 = mraa_gpio_init(9);

pclk = mraa_gpio_init(10);

href = mraa_gpio_init(11);

vsync = mraa_gpio_init(12);

mraa_gpio_dir(d0, MRAA_GPIO_IN);

mraa_gpio_dir(d1, MRAA_GPIO_IN);

mraa_gpio_dir(d2, MRAA_GPIO_IN);

mraa_gpio_dir(d3, MRAA_GPIO_IN);

mraa_gpio_dir(d4, MRAA_GPIO_IN);

mraa_gpio_dir(d5, MRAA_GPIO_IN);

mraa_gpio_dir(d6, MRAA_GPIO_IN);

mraa_gpio_dir(d7, MRAA_GPIO_IN);

mraa_gpio_dir(href, MRAA_GPIO_IN);

mraa_gpio_dir(vsync, MRAA_GPIO_IN);

mraa_gpio_edge_mode(pclk, MRAA_GPIO_EDGE_RISING);

int data[7];

int byte;

int counter = 0;

Mat image(480,640,CV_8UC1);

while(1){

int shref = mraa_gpio_read(href);

int svsync = mraa_gpio_read(vsync);

int fpclk = mraa_gpio_read(pclk);

if (svsync==0 && shref==1 && fpclk==1){

data[0] = mraa_gpio_read(d0) ;

data[1] = mraa_gpio_read(d1) ;

data[2] = mraa_gpio_read(d2) ;

data[3] = mraa_gpio_read(d3) ;

data[4] = mraa_gpio_read(d4) ;

data[5] = mraa_gpio_read(d5) ;

data[6] = mraa_gpio_read(d6) ;

data[7] = mraa_gpio_read(d7) ;

byte = (data[7]<<7) | (data[6]<<6) | (data[5]<<5) | (data[4]<<4) |

(data[3]<<3) | (data[2]<<2) | (data[1]<<1) | (data[0]) ;

if(counter == 1) {

//do gray scale input to mat container

}

else if(counter == 2){

counter = 0;

}

else;

counter++;

}

else;

}

}

-----------------------------------------------------------------------------------------------------------------------------------

the command i use to compile is : g++ -lmraa -lopencv_highgui -lopencv_core -lopencv_imgproc -o camread camread.cpp

 

and i also checked the forum you linked to regarding the library issue, and when i went to my /usr/lib/pkgconfig/ folder in my edison i couldnt find the opencv.pc file. this could also be a reason why im getting the error message

idata
Community Manager
94 Views

Hi Prashanth93,

 

 

I would like to give it a try myself. I'm not sure if there's an error with the libraries or with the code. I would also like to set up OpenCV on my Intel Edison to see if this is an error with your installation or maybe with the installation process itself. Have you tried using python before? While I run some tests you can play with python to see if you get different results.

 

 

Regards,

 

Pablo
idata
Community Manager
94 Views

Hi Prashanth93,

 

 

I've been trying to make your code work using this guide to install OpenCV, https://software.intel.com/en-us/articles/opencv-300-ipp-tbb-enabled-on-yocto-with-intel-edison https://software.intel.com/en-us/articles/opencv-300-ipp-tbb-enabled-on-yocto-with-intel-edison. However, I've been unable to get it working. First I had some troubles with this line "namespace cv" but it was some installation issue, once I encountered the error I tried to compile your program once more and encountered a similar error message to the one you're getting.

 

After that, I used AlexT repository to install OpenCV (the only drawback is that it is v2.4) and got a successful compilation using this process. I would suggest to try this way and you might get better results.

 

 

Regards,

 

Pablo
PPoob
New Contributor I
94 Views

thanks pablo,

but how to install opencv from the alexT repo also i saw his repo list in the /etc/opkg/base-feeds.conf to be identical to whats already in my edison.

which are the :

src/gz all http://repo.opkg.net/edison/repo/all

src/gz edison http://repo.opkg.net/edison/repo/edison

src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32

and how do i install opencv form the repository ?

idata
Community Manager
94 Views

Hi Prashanth,

 

 

You'll just need to use the command opkg install name-of-the-package, with this you'll start fetching the package from the repository and then you'll install it. Take a look at his repository packages in here http://repo.opkg.net/edison/repo/ http://repo.opkg.net/edison/repo/, go to core2-32/ and search for all the openCV available packages (development tools and libraries).

 

If you're willing to give Python a try you can check this guide which contains some useful information about openCV and Python, http://makezine.com/projects/make-43/photographic-memory/ http://makezine.com/projects/make-43/photographic-memory/.

 

 

Regards,

 

Pablo
PPoob
New Contributor I
94 Views

yup i finally got opencv working, truns out it was quite easy to configure, unlike the intel documentation... which only irritates me how misleading the whole thing is. intel should really do a better job at providing better documnetation

anyhow heres what i did i went to alexT repo, followed the instruction there(http://alextgalileo.altervista.org/edison-package-repo-configuration-instructions.html Edison Package Repo Configuration Instructions )

then i typed in

opkg install opencv

opkg install libopencv-core2.4

opkg install libopencv-core-dev

and that was it !!

i could compile my code using "g++ -lopencv_highgui -lopencv_core -lopencv_imgproc -lopencv_objdetect -lmraa -o facecount facecount.cpp"

since and succssfully ran a haar casscade code to count number of faces

thanks a million Pablo,

i couldnt have done it without your help !!!

--prashanth

Reply