Fonction suivi moteur et presentation html

This commit is contained in:
Jacques Zhong 2017-05-01 20:40:59 +02:00
parent 997eb6e8a5
commit 81ea78a32d
71 changed files with 1609 additions and 2875 deletions

View file

@ -1,13 +1,9 @@
#include <cv.h>
#include <highgui.h>
#include <cxcore.h>
//#include <cxcore.h>
//callback for trackbar. nothing to be done here
void on_trackbar( int, void* )
{
}
//#include <SFML/Window.hpp>
int main(int argc, char* argv[])
{
@ -30,6 +26,9 @@ int main(int argc, char* argv[])
cvNamedWindow( "Camera", CV_WINDOW_AUTOSIZE );
cvNamedWindow( "HSV", CV_WINDOW_AUTOSIZE );
cvNamedWindow( "Binaire", CV_WINDOW_AUTOSIZE );
//sf::Window window;
//window.create(sf::VideoMode(800, 600), "My window",sf::Style::Default);
// get the image data
height = frame->height;
@ -56,6 +55,7 @@ int main(int argc, char* argv[])
int iLowV = 101;
int iHighV = 255;
//Create trackbars in "Control" window
cvCreateTrackbar("LowH", "Control", &iLowH, 179); //Hue (0 - 179)
cvCreateTrackbar("HighH", "Control", &iHighH, 179);
@ -65,6 +65,7 @@ int main(int argc, char* argv[])
cvCreateTrackbar("LowV", "Control", &iLowV, 255); //Value (0 - 255)
cvCreateTrackbar("HighV", "Control", &iHighV, 255);
while( 1 )
{
@ -79,10 +80,14 @@ int main(int argc, char* argv[])
// Covert color space to HSV as it is much easier to filter colors in the HSV color-space.
cvCvtColor(frame, hsv_frame, CV_BGR2HSV);
//Binarisation
//Blur
cvSmooth( hsv_frame, hsv_frame, CV_GAUSSIAN, 15, 15); //suppression des parasites par flou gaussien
//Binarisation
cvInRangeS(hsv_frame, cvScalar(iLowH, iLowS, iLowV), cvScalar(iHighH, iHighS, iHighV), threshold);
//Blur
cvSmooth( threshold, threshold, CV_GAUSSIAN, 9, 9 ); //Legère suppression des parasites
//cvSmooth( threshold, threshold, CV_GAUSSIAN, 9, 9 ); //Legère suppression des parasites
// Calculate the moments to estimate the position of the ball
@ -95,7 +100,12 @@ int main(int argc, char* argv[])
posX= moment10/area;
posY= moment01/area;
cvCircle(frame, cvPoint(posX,posY), 5, cvScalar(0,0,255), -1, 8, 0 );
//Affichage zone suivie objet
cvCircle(frame, cvPoint(width/2,height/2), 100, CV_RGB(255, 0, 0), 4, 8, 0 );
//Affichage position de l'objet
cvLine(frame, cvPoint(posX-20,posY), cvPoint(posX+20,posY), CV_RGB(0, 0, 255), 4, 8, 0 );
cvLine(frame, cvPoint(posX,posY-20), cvPoint(posX,posY+20), CV_RGB(0, 0, 255), 4, 8, 0 );
cvShowImage( "Camera", frame ); // Original stream with detected ball overlay
cvShowImage( "HSV", hsv_frame); // Original stream in the HSV color space