kelvinlow
Posts: 12
Joined: Wed May 18, 2016 8:43 am

Compiling OpenCV sample codes failed

Sun May 29, 2016 7:24 pm

Hello, I just googled a lot about this but I found nothing.
I'm trying to compile cpp file which included in /home/pi/opencv-3.1.0/samples/cpp
I opened the file in Code:Block, and trying to compile by G++
And I got a lot of mistake, so I know I am doing wrong to compile it

Image
How do I compile these files?
Last edited by kelvinlow on Mon May 30, 2016 2:13 am, edited 2 times in total.

kelvinlow
Posts: 12
Joined: Wed May 18, 2016 8:43 am

Re: How do I compile sample cpp files included by OpenCV?

Sun May 29, 2016 7:26 pm

Should I make a project with OpenCV library included?

kelvinlow
Posts: 12
Joined: Wed May 18, 2016 8:43 am

Re: How do I compile sample cpp files included by OpenCV?

Sun May 29, 2016 7:45 pm

Hey guys, thank for passing by
I just googled that I have to use command like this

Code: Select all

g++ -ggdb `pkg-config --cflags --libs opencv` facedetect.cpp -o facedetect
I did, and it's works, but I am facing problem when I'm trying to run it
Image

Code: Select all

(process:2534): Gtk-WARNING **: Locale not supported by C library.
	Using the fallback 'C' locale.

(Edge map:2534): Gtk-WARNING **: cannot open display: 
Any solution to fix this problem? =(

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: How do I compile sample cpp files included by OpenCV?

Sun May 29, 2016 7:46 pm

You must have the GUI open while running that or if running it remotely, type:
export DISPLAY=:0
first
There are 10 types of people: those who understand binary and those who don't.

kelvinlow
Posts: 12
Joined: Wed May 18, 2016 8:43 am

Re: How do I compile sample cpp files included by OpenCV?

Sun May 29, 2016 9:10 pm

kusti8 wrote:You must have the GUI open while running that or if running it remotely, type:
export DISPLAY=:0
first
Thanks Kuisti8, but this is not working on LXTerminal.
I was doing this on my Terminal with SSH connected to my RPi
and now I'm doing this on LXTerminal with remote controlled.

Before you told me to add 'export DISPLAY=:0'
I get an error messege like this

Code: Select all

 (Edge map:3470) GdkGLExt-WARNING **: Window system doesn't support OpenGL. 
After I did your instruction by typing 'export DISPLAY=:0'
Now I get this error

Code: Select all

 No protocol specified
(Edge map:3509): Gtk-WARNING ** : cannot open display : :0 
I need your help =(

kelvinlow
Posts: 12
Joined: Wed May 18, 2016 8:43 am

Re: How do I compile sample cpp files included by OpenCV?

Sun May 29, 2016 9:15 pm

If I am running those samples on RPi, how do I do?
If I am running those samples via SSH on my Mac, how do I do?

Please help if you know how to do so, THANK YOU!!

kelvinlow
Posts: 12
Joined: Wed May 18, 2016 8:43 am

Re: How do I compile sample cpp files included by OpenCV?

Sun May 29, 2016 9:28 pm

kusti8 wrote:You must have the GUI open while running that or if running it remotely, type:
export DISPLAY=:0
first
Thank kusti8,
How do I have the GUI open while running ?

Return to “General discussion”