-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
059e21e
commit 4012633
Showing
35 changed files
with
14,590 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
project( camcv ) | ||
SET(COMPILE_DEFINITIONS -Werror) | ||
|
||
#OPENCV | ||
find_package( OpenCV REQUIRED ) | ||
|
||
link_directories( /home/pi/libs/libfacerec ) | ||
|
||
set (GL_SCENE_SOURCES | ||
gl_scenes/models.c | ||
gl_scenes/mirror.c | ||
gl_scenes/yuv.c | ||
gl_scenes/sobel.c | ||
gl_scenes/square.c | ||
gl_scenes/teapot.c) | ||
SET(CMAKE_EXE_LINKER_FLAGS "-lpthread") | ||
include_directories(/home/pi/camcv/raspicam/gl_scenes) | ||
include_directories(/opt/vc/include) | ||
include_directories(/opt/vc/include/EGL) | ||
include_directories(/opt/vc/userland-master/host_applications/linux/libs/bcm_host/include) | ||
include_directories(/opt/vc/userland/interface/vcos) | ||
include_directories(/opt/vc/userland) | ||
include_directories(/opt/vc/userland/interface/vcos/pthreads) | ||
include_directories(/opt/vc/userland/interface/vmcs_host/linux) | ||
include_directories(/home/pi/camcv) | ||
include_directories(/home/pi/camcv/raspicam) | ||
add_executable(camcv RaspiCamControl.c RaspiCLI.c RaspiPreview.c | ||
GPIOClass.cpp | ||
camcv.cpp RaspiTex.c RaspiTexUtil.c tga.c ${GL_SCENE_SOURCES}) | ||
target_link_libraries(camcv m /opt/vc/lib/libmmal_core.so /opt/vc/lib/libmmal_util.so /opt/vc/lib/libmmal_vc_client.so /opt/vc/lib/libvcos.so /opt/vc/lib/libbcm_host.so /opt/vc/lib/libGLESv2.so /opt/vc/lib/libEGL.so /home/pi/libs/libfacerec/libopencv_facerec.a wiringPi pthread ${OpenCV_LIBS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#include <fstream> | ||
#include <string> | ||
#include <iostream> | ||
#include <sstream> | ||
#include "GPIOClass.h" | ||
|
||
using namespace std; | ||
|
||
GPIOClass::GPIOClass(){ | ||
this->gpionum = "4"; //GPIO4 is default | ||
} | ||
|
||
GPIOClass::GPIOClass(string gnum){ | ||
this->gpionum = gnum; //Instatiate GPIOClass object for GPIO pin number "gnum" | ||
} | ||
|
||
int GPIOClass::export_gpio(){ | ||
string export_str = "/sys/class/gpio/export"; | ||
ofstream exportgpio(export_str.c_str()); // Open "export" file. Convert C++ string to C string. Required for all Linux pathnames | ||
if (exportgpio < 0){ | ||
cout << " OPERATION FAILED: Unable to export GPIO"<< this->gpionum <<" ."<< endl; | ||
return -1; | ||
} | ||
|
||
exportgpio << this->gpionum ; //write GPIO number to export | ||
exportgpio.close(); //close export file | ||
return 0; | ||
} | ||
|
||
int GPIOClass::unexport_gpio(){ | ||
string unexport_str = "/sys/class/gpio/unexport"; | ||
ofstream unexportgpio(unexport_str.c_str()); //Open unexport file | ||
if (unexportgpio < 0){ | ||
cout << " OPERATION FAILED: Unable to unexport GPIO"<< this->gpionum <<" ."<< endl; | ||
return -1; | ||
} | ||
|
||
unexportgpio << this->gpionum ; //write GPIO number to unexport | ||
unexportgpio.close(); //close unexport file | ||
return 0; | ||
} | ||
|
||
int GPIOClass::setdir_gpio(string dir){ | ||
string setdir_str ="/sys/class/gpio/gpio" + this->gpionum + "/direction"; | ||
ofstream setdirgpio(setdir_str.c_str()); // open direction file for gpio | ||
if (setdirgpio < 0){ | ||
cout << " OPERATION FAILED: Unable to set direction of GPIO"<< this->gpionum <<" ."<< endl; | ||
return -1; | ||
} | ||
|
||
setdirgpio << dir; //write direction to direction file | ||
setdirgpio.close(); // close direction file | ||
return 0; | ||
} | ||
|
||
int GPIOClass::setval_gpio(string val){ | ||
string setval_str = "/sys/class/gpio/gpio" + this->gpionum + "/value"; | ||
ofstream setvalgpio(setval_str.c_str()); // open value file for gpio | ||
if (setvalgpio < 0){ | ||
cout << " OPERATION FAILED: Unable to set the value of GPIO"<< this->gpionum <<" ."<< endl; | ||
return -1; | ||
} | ||
|
||
setvalgpio << val ;//write value to value file | ||
setvalgpio.close();// close value file | ||
return 0; | ||
} | ||
|
||
int GPIOClass::getval_gpio(string& val){ | ||
string getval_str = "/sys/class/gpio/gpio" + this->gpionum + "/value"; | ||
ifstream getvalgpio(getval_str.c_str());// open value file for gpio | ||
if (getvalgpio < 0){ | ||
cout << " OPERATION FAILED: Unable to get value of GPIO"<< this->gpionum <<" ."<< endl; | ||
return -1; | ||
} | ||
|
||
getvalgpio >> val ; //read gpio value | ||
|
||
if(val != "0") | ||
val = "1"; | ||
else | ||
val = "0"; | ||
|
||
getvalgpio.close(); //close the value file | ||
return 0; | ||
} | ||
|
||
string GPIOClass::get_gpionum(){ | ||
return this->gpionum; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef GPIO_CLASS_H | ||
#define GPIO_CLASS_H | ||
|
||
#include <string> | ||
using namespace std; | ||
/* GPIO Class | ||
* Purpose: Each object instantiated from this class will control a GPIO pin | ||
* The GPIO pin number must be passed to the overloaded class constructor | ||
*/ | ||
class GPIOClass | ||
{ | ||
public: | ||
GPIOClass(); // create a GPIO object that controls GPIO4 (default | ||
GPIOClass(string x); // create a GPIO object that controls GPIOx, where x is passed to this constructor | ||
int export_gpio(); // exports GPIO | ||
int unexport_gpio(); // unexport GPIO | ||
int setdir_gpio(string dir); // Set GPIO Direction | ||
int setval_gpio(string val); // Set GPIO Value (putput pins) | ||
int getval_gpio(string& val); // Get GPIO Value (input/ output pins) | ||
string get_gpionum(); // return the GPIO number associated with the instance of an object | ||
private: | ||
string gpionum; // GPIO number associated with the instance of an object | ||
}; | ||
|
||
#endif |
Oops, something went wrong.