Skip to content

Instantly share code, notes, and snippets.

View ollewelin's full-sized avatar

Olle Welin ollewelin

View GitHub Profile
//File: simpletest_raspicam_cv.cpp
//Will test Trained Cascade Object detection
#include <opencv2/highgui/highgui.hpp> // OpenCV window I/O
#include <opencv2/imgproc/imgproc.hpp> // Gaussian Blur
#include <stdio.h>
#include <raspicam/raspicam_cv.h>
#include <opencv2/opencv.hpp>
#include "gpio_test.h"
#include <bcm2835.h>
//File: gpio_test.c
#include "gpio_test.h"
int gpio_init(void)
{
if (!bcm2835_init())
return 1;
// Set the pin to be an output
bcm2835_gpio_fsel(RPI_GPIO_P1_11, BCM2835_GPIO_FSEL_OUTP);
bcm2835_gpio_fsel(PIN12, BCM2835_GPIO_FSEL_INPT);// Input pin
return 0;
//gpio_test.h
#include <bcm2835.h>
#define PIN RPI_GPIO_P1_11
#include <stdio.h>
#define PIN12 RPI_GPIO_P1_12
int gpio_init(void);
void gpio_close(void);
#File CMakeLists.txt
#type
#sudo cmake ./CMakeLists.txt
#in /home/pi/OlleOpenCV2_3 foleder to make a makefile
#type then
#sudo make
#to compile
#####################################
cmake_minimum_required (VERSION 2.8)
<?xml version="1.0"?>
<opencv_storage>
<cascade>
<stageType>BOOST</stageType>
<featureType>LBP</featureType>
<height>24</height>
<width>32</width>
<stageParams>
<boostType>LB</boostType>
<minHitRate>9.9500000476837158e-01</minHitRate>
//Generate Positive samples
//File: test_prog.cpp
//You must make a director /positive_data/ where this program could put the pictures in
#include <stdio.h>
#include <unistd.h>
#include <ctime>
#include <iostream>
#include <raspicam/raspicam_cv.h>
using namespace std;
#File: CMakeLists.txt
#be in /home/pi/pos_neg directory and type:
#sudo cmake ./CMakeLists.txt
#sudo make
#sudo ./test_prog
#####################################
cmake_minimum_required (VERSION 2.8)
project (raspicam_test)
set(CMAKE_MODULE_PATH "/usr/local/lib/cmake/${CMAKE_MODULE_PATH}")
//Generate Negative samples
//File: test_prog.cpp
//You must make a director /positive_data/ where this program could put the pictures in
#include <stdio.h>
#include <ctime>
#include <iostream>
#include <raspicam/raspicam_cv.h>
using namespace std;
#File: CMakeLists.txt
#be in /home/pi/negative directory and type:
#sudo cmake ./CMakeLists.txt
#sudo make
#sudo ./test_prog
#####################################
cmake_minimum_required (VERSION 2.8)
project (raspicam_test)
set(CMAKE_MODULE_PATH "/usr/local/lib/cmake/${CMAKE_MODULE_PATH}")
opencv_createsamples -info info.txt -num 2000 -w 32 -h 24 -vec logo.vec -maxxangle 2.0 -maxyangle 2.0 -maxzangle 2.0 -maxidev 800 -bgthresh 160
opencv_createsamples -vec logo.vec -w 32 -h 24
opencv_traincascade -data data -vec logo.vec -bg bg.txt -precalcValBufSize 768 -precalcIdxBufSize 768 -numPos 1900 -numNeg 1000 -numStages 8 -w 32 -h 24 -featureType LBP -mode ALL -maxFalseAlarmRate 0.1