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 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 |
No comments:
Post a Comment