Showing posts with label face recognize. Show all posts
Showing posts with label face recognize. Show all posts

Sep 15, 2015

RaspiberryPi openCV with wiringPi


My last post GPIO control for raspberry openCV is use system() function.

This post use wiringpi library.

I forgot wiringPi initialize.

If you added wiringPiSetup(), wiringPi is work.

You can download my changed code.

Backup your camcv_vid1.cpp and CMakeLists.txt files.

Extract zip files

And compile and build(cmake and make.)

RUN

If you see this error



Need a root.

So, you will typing this.

1
sudo ./camcv others/csv.txt l 2000
cs

GPIO control for raspberry openCV



There are many library for GPIO control.

Usually we use wiringPi.

But difficult compile wiringPi in cmake of camcv. 

Compile is ok but code does not run.

I added CmakeList.txt

CmakeList.txt
1
2
3
SET(CMAKE_CXX_FLAGS "-pthread -I/usr/local/include -L/usr/local/lib -lwiringPi")
include_directories(/usr/local/include/)
target_link_libraries(/usr/local/lib/libwiringPi.so /usr/local/lib/libwiringPiDev.so )
cs

Added  camcv_vid1.cpp
1
#include <wiringPi.h>
cs

Added main() function code
1
2
    pinMode(0, OUTPUT);    // output mode
    digitalWrite(0, 0);    //output low
cs

Added in recognize function code
1
    digitalWrite(0, 1);    //output high
cs



But doesn't run. So I tried another method.

shell command!!

I referred digipine.com 

system() function is shell command function.

Added main() function code.

1
2
system("gpio mode 0 out");    //ans 
system("gpio write 0 0");    //ans
cs

GPIO 0 -> output
GPIO 0 -> low

Added in recognize function code
1
2
3
4
5
6
7
8
// display name of the guy on the picture
string box_text;
if (prediction<MAX_PEOPLE)
{
    box_text = "Id="+people[prediction];
    if (prediction == P_NATACHA) //ans
        system("gpio write 0 1");    //ans
}
cs

If recognized natacha, gpio 0 is high.

I referred wiringpi.com 

I use code is
1
2
3
gpio mode 0 out //gpio 0 output 
gpio write 0 0  //gpio 0 low 
gpio write 0 1  //gpio 0 high
cs