Mergin itseez
This commit is contained in:
@@ -76,5 +76,3 @@ void Morphology_Operations( int, void* )
|
||||
morphologyEx( src, dst, operation, element );
|
||||
imshow( window_name, dst );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -66,10 +66,3 @@ int main( void )
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -61,5 +61,3 @@ int main( int, char** argv )
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -15,7 +15,6 @@ using namespace cv;
|
||||
Mat src, dst;
|
||||
int top, bottom, left, right;
|
||||
int borderType;
|
||||
Scalar value;
|
||||
const char* window_name = "copyMakeBorder Demo";
|
||||
RNG rng(12345);
|
||||
|
||||
@@ -64,7 +63,7 @@ int main( int, char** argv )
|
||||
else if( (char)c == 'r' )
|
||||
{ borderType = BORDER_REPLICATE; }
|
||||
|
||||
value = Scalar( rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255) );
|
||||
Scalar value( rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255) );
|
||||
copyMakeBorder( src, dst, top, bottom, left, right, borderType, value );
|
||||
|
||||
imshow( window_name, dst );
|
||||
@@ -72,5 +71,3 @@ int main( int, char** argv )
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -92,4 +92,3 @@ void thresh_callback(int, void* )
|
||||
circle( drawing, mc[i], 4, color, -1, 8, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -79,5 +79,3 @@ int main( void )
|
||||
waitKey(0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -120,4 +120,3 @@ void myHarris_function( int, void* )
|
||||
}
|
||||
imshow( myHarris_window, myHarris_copy );
|
||||
}
|
||||
|
||||
|
@@ -102,4 +102,3 @@ void goodFeaturesToTrack_Demo( int, void* )
|
||||
for( size_t i = 0; i < corners.size(); i++ )
|
||||
{ cout<<" -- Refined Corner ["<<i<<"] ("<<corners[i].x<<","<<corners[i].y<<")"<<endl; }
|
||||
}
|
||||
|
||||
|
@@ -90,4 +90,3 @@ void goodFeaturesToTrack_Demo( int, void* )
|
||||
namedWindow( source_window, WINDOW_AUTOSIZE );
|
||||
imshow( source_window, copy );
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
#include "opencv2/contrib.hpp"
|
||||
#include "opencv2/bioinspired.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
|
||||
static void help(std::string errorMessage)
|
||||
@@ -95,16 +95,16 @@ int main(int argc, char* argv[]) {
|
||||
try
|
||||
{
|
||||
// create a retina instance with default parameters setup, uncomment the initialisation you wanna test
|
||||
cv::Ptr<cv::Retina> myRetina;
|
||||
cv::Ptr<cv::bioinspired::Retina> myRetina;
|
||||
|
||||
// if the last parameter is 'log', then activate log sampling (favour foveal vision and subsamples peripheral vision)
|
||||
if (useLogSampling)
|
||||
{
|
||||
myRetina = cv::createRetina(inputFrame.size(), true, cv::RETINA_COLOR_BAYER, true, 2.0, 10.0);
|
||||
myRetina = cv::bioinspired::createRetina(inputFrame.size(), true, cv::bioinspired::RETINA_COLOR_BAYER, true, 2.0, 10.0);
|
||||
}
|
||||
else// -> else allocate "classical" retina :
|
||||
{
|
||||
myRetina = cv::createRetina(inputFrame.size());
|
||||
myRetina = cv::bioinspired::createRetina(inputFrame.size());
|
||||
}
|
||||
|
||||
// save default retina parameters file in order to let you see this and maybe modify it and reload using method "setup"
|
@@ -168,5 +168,3 @@ void MyLine( Mat img, Point start, Point end )
|
||||
thickness,
|
||||
lineType );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -75,4 +75,4 @@ int main(int argc, char ** argv)
|
||||
waitKey();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -151,4 +151,4 @@ int main(int ac, char** av)
|
||||
<< "Tip: Open up " << filename << " with a text editor to see the serialized data." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -214,4 +214,4 @@ Mat& ScanImageAndReduceRandomAccess(Mat& I, const uchar* const table)
|
||||
}
|
||||
|
||||
return I;
|
||||
}
|
||||
}
|
||||
|
@@ -32,8 +32,8 @@ int main( int argc, char** argv )
|
||||
const char* imagename = argc > 1 ? argv[1] : "lena.jpg";
|
||||
|
||||
#ifdef DEMO_MIXED_API_USE
|
||||
Ptr<IplImage> IplI = cvLoadImage(imagename); // Ptr<T> is safe ref-counting pointer class
|
||||
if(IplI.empty())
|
||||
Ptr<IplImage> IplI(cvLoadImage(imagename)); // Ptr<T> is a safe ref-counting pointer class
|
||||
if(!IplI)
|
||||
{
|
||||
cerr << "Can not load image " << imagename << endl;
|
||||
return -1;
|
||||
|
@@ -84,4 +84,4 @@ void Sharpen(const Mat& myImage,Mat& Result)
|
||||
Result.row(Result.rows-1).setTo(Scalar(0));
|
||||
Result.col(0).setTo(Scalar(0));
|
||||
Result.col(Result.cols-1).setTo(Scalar(0));
|
||||
}
|
||||
}
|
||||
|
@@ -82,4 +82,4 @@ int main(int,char**)
|
||||
|
||||
cout << "A vector of 2D Points = " << vPoints << endl << endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -430,4 +430,3 @@ Scalar getMSSIM_GPU_optimized( const Mat& i1, const Mat& i2, BufferMSSIM& b)
|
||||
}
|
||||
return mssim;
|
||||
}
|
||||
|
||||
|
@@ -27,4 +27,4 @@ int main( int argc, char** argv )
|
||||
|
||||
waitKey(0); // Wait for a keystroke in the window
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -203,4 +203,4 @@ Scalar getMSSIM( const Mat& i1, const Mat& i2)
|
||||
|
||||
Scalar mssim = mean( ssim_map ); // mssim = average of ssim map
|
||||
return mssim;
|
||||
}
|
||||
}
|
||||
|
@@ -127,4 +127,4 @@ int main()
|
||||
imwrite("result.png", I); // save the Image
|
||||
imshow("SVM for Non-Linear Training Data", I); // show it to the user
|
||||
waitKey(0);
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,6 @@
|
||||
/**
|
||||
* @file objectDetection.cpp
|
||||
* @author A. Huaman ( based in the classic facedetect.cpp in samples/c )
|
||||
* @brief A simplified version of facedetect.cpp, show how to load a cascade classifier and how to find objects (Face + eyes) in a video stream
|
||||
*/
|
||||
#include "opencv2/objdetect/objdetect.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
#include "opencv2/highgui/highgui_c.h"
|
||||
#include "opencv2/objdetect.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
@@ -20,79 +12,73 @@ using namespace cv;
|
||||
void detectAndDisplay( Mat frame );
|
||||
|
||||
/** Global variables */
|
||||
//-- Note, either copy these two files from opencv/data/haarscascades to your current folder, or change these locations
|
||||
string face_cascade_name = "haarcascade_frontalface_alt.xml";
|
||||
string eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
|
||||
String face_cascade_name = "haarcascade_frontalface_alt.xml";
|
||||
String eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
|
||||
CascadeClassifier face_cascade;
|
||||
CascadeClassifier eyes_cascade;
|
||||
string window_name = "Capture - Face detection";
|
||||
RNG rng(12345);
|
||||
String window_name = "Capture - Face detection";
|
||||
|
||||
/**
|
||||
* @function main
|
||||
*/
|
||||
/** @function main */
|
||||
int main( void )
|
||||
{
|
||||
CvCapture* capture;
|
||||
Mat frame;
|
||||
VideoCapture capture;
|
||||
Mat frame;
|
||||
|
||||
//-- 1. Load the cascades
|
||||
if( !face_cascade.load( face_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; };
|
||||
if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; };
|
||||
//-- 1. Load the cascades
|
||||
if( !face_cascade.load( face_cascade_name ) ){ printf("--(!)Error loading face cascade\n"); return -1; };
|
||||
if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)Error loading eyes cascade\n"); return -1; };
|
||||
|
||||
//-- 2. Read the video stream
|
||||
capture = cvCaptureFromCAM( -1 );
|
||||
if( capture )
|
||||
{
|
||||
for(;;)
|
||||
//-- 2. Read the video stream
|
||||
capture.open( -1 );
|
||||
if ( ! capture.isOpened() ) { printf("--(!)Error opening video capture\n"); return -1; }
|
||||
|
||||
while ( capture.read(frame) )
|
||||
{
|
||||
frame = cv::cvarrToMat(cvQueryFrame( capture ));
|
||||
if( frame.empty() )
|
||||
{
|
||||
printf(" --(!) No captured frame -- Break!");
|
||||
break;
|
||||
}
|
||||
|
||||
//-- 3. Apply the classifier to the frame
|
||||
if( !frame.empty() )
|
||||
{ detectAndDisplay( frame ); }
|
||||
else
|
||||
{ printf(" --(!) No captured frame -- Break!"); break; }
|
||||
|
||||
int c = waitKey(10);
|
||||
if( (char)c == 'c' ) { break; }
|
||||
//-- 3. Apply the classifier to the frame
|
||||
detectAndDisplay( frame );
|
||||
|
||||
int c = waitKey(10);
|
||||
if( (char)c == 27 ) { break; } // escape
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @function detectAndDisplay
|
||||
*/
|
||||
/** @function detectAndDisplay */
|
||||
void detectAndDisplay( Mat frame )
|
||||
{
|
||||
std::vector<Rect> faces;
|
||||
Mat frame_gray;
|
||||
std::vector<Rect> faces;
|
||||
Mat frame_gray;
|
||||
|
||||
cvtColor( frame, frame_gray, COLOR_BGR2GRAY );
|
||||
equalizeHist( frame_gray, frame_gray );
|
||||
//-- Detect faces
|
||||
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CASCADE_SCALE_IMAGE, Size(30, 30) );
|
||||
cvtColor( frame, frame_gray, COLOR_BGR2GRAY );
|
||||
equalizeHist( frame_gray, frame_gray );
|
||||
|
||||
for( size_t i = 0; i < faces.size(); i++ )
|
||||
//-- Detect faces
|
||||
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CASCADE_SCALE_IMAGE, Size(30, 30) );
|
||||
|
||||
for ( size_t i = 0; i < faces.size(); i++ )
|
||||
{
|
||||
Point center( faces[i].x + faces[i].width/2, faces[i].y + faces[i].height/2 );
|
||||
ellipse( frame, center, Size( faces[i].width/2, faces[i].height/2), 0, 0, 360, Scalar( 255, 0, 255 ), 2, 8, 0 );
|
||||
Point center( faces[i].x + faces[i].width/2, faces[i].y + faces[i].height/2 );
|
||||
ellipse( frame, center, Size( faces[i].width/2, faces[i].height/2 ), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
|
||||
|
||||
Mat faceROI = frame_gray( faces[i] );
|
||||
std::vector<Rect> eyes;
|
||||
Mat faceROI = frame_gray( faces[i] );
|
||||
std::vector<Rect> eyes;
|
||||
|
||||
//-- In each face, detect eyes
|
||||
eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CASCADE_SCALE_IMAGE, Size(30, 30) );
|
||||
//-- In each face, detect eyes
|
||||
eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CASCADE_SCALE_IMAGE, Size(30, 30) );
|
||||
|
||||
for( size_t j = 0; j < eyes.size(); j++ )
|
||||
{
|
||||
Point eye_center( faces[i].x + eyes[j].x + eyes[j].width/2, faces[i].y + eyes[j].y + eyes[j].height/2 );
|
||||
int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 );
|
||||
circle( frame, eye_center, radius, Scalar( 255, 0, 0 ), 3, 8, 0 );
|
||||
}
|
||||
for ( size_t j = 0; j < eyes.size(); j++ )
|
||||
{
|
||||
Point eye_center( faces[i].x + eyes[j].x + eyes[j].width/2, faces[i].y + eyes[j].y + eyes[j].height/2 );
|
||||
int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 );
|
||||
circle( frame, eye_center, radius, Scalar( 255, 0, 0 ), 4, 8, 0 );
|
||||
}
|
||||
}
|
||||
//-- Show what you got
|
||||
imshow( window_name, frame );
|
||||
//-- Show what you got
|
||||
imshow( window_name, frame );
|
||||
}
|
||||
|
@@ -3,12 +3,9 @@
|
||||
* @author A. Huaman ( based in the classic facedetect.cpp in samples/c )
|
||||
* @brief A simplified version of facedetect.cpp, show how to load a cascade classifier and how to find objects (Face + eyes) in a video stream - Using LBP here
|
||||
*/
|
||||
#include "opencv2/objdetect/objdetect.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
#include "opencv2/highgui/highgui_c.h"
|
||||
#include "opencv2/objdetect.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
@@ -20,46 +17,43 @@ using namespace cv;
|
||||
void detectAndDisplay( Mat frame );
|
||||
|
||||
/** Global variables */
|
||||
string face_cascade_name = "lbpcascade_frontalface.xml";
|
||||
string eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
|
||||
String face_cascade_name = "lbpcascade_frontalface.xml";
|
||||
String eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
|
||||
CascadeClassifier face_cascade;
|
||||
CascadeClassifier eyes_cascade;
|
||||
string window_name = "Capture - Face detection";
|
||||
|
||||
RNG rng(12345);
|
||||
|
||||
String window_name = "Capture - Face detection";
|
||||
/**
|
||||
* @function main
|
||||
*/
|
||||
int main( void )
|
||||
{
|
||||
CvCapture* capture;
|
||||
Mat frame;
|
||||
VideoCapture capture;
|
||||
Mat frame;
|
||||
|
||||
//-- 1. Load the cascade
|
||||
if( !face_cascade.load( face_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; };
|
||||
if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)Error loading\n"); return -1; };
|
||||
//-- 1. Load the cascade
|
||||
if( !face_cascade.load( face_cascade_name ) ){ printf("--(!)Error loading face cascade\n"); return -1; };
|
||||
if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)Error loading eyes cascade\n"); return -1; };
|
||||
|
||||
//-- 2. Read the video stream
|
||||
capture = cvCaptureFromCAM( -1 );
|
||||
if( capture )
|
||||
{
|
||||
for(;;)
|
||||
//-- 2. Read the video stream
|
||||
capture.open( -1 );
|
||||
if ( ! capture.isOpened() ) { printf("--(!)Error opening video capture\n"); return -1; }
|
||||
|
||||
while ( capture.read(frame) )
|
||||
{
|
||||
frame = cv::cvarrToMat(cvQueryFrame( capture ));
|
||||
if( frame.empty() )
|
||||
{
|
||||
printf(" --(!) No captured frame -- Break!");
|
||||
break;
|
||||
}
|
||||
|
||||
//-- 3. Apply the classifier to the frame
|
||||
if( !frame.empty() )
|
||||
{ detectAndDisplay( frame ); }
|
||||
else
|
||||
{ printf(" --(!) No captured frame -- Break!"); break; }
|
||||
|
||||
int c = waitKey(10);
|
||||
if( (char)c == 'c' ) { break; }
|
||||
//-- 3. Apply the classifier to the frame
|
||||
detectAndDisplay( frame );
|
||||
|
||||
//-- bail out if escape was pressed
|
||||
int c = waitKey(10);
|
||||
if( (char)c == 27 ) { break; }
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,37 +61,37 @@ int main( void )
|
||||
*/
|
||||
void detectAndDisplay( Mat frame )
|
||||
{
|
||||
std::vector<Rect> faces;
|
||||
Mat frame_gray;
|
||||
std::vector<Rect> faces;
|
||||
Mat frame_gray;
|
||||
|
||||
cvtColor( frame, frame_gray, COLOR_BGR2GRAY );
|
||||
equalizeHist( frame_gray, frame_gray );
|
||||
cvtColor( frame, frame_gray, COLOR_BGR2GRAY );
|
||||
equalizeHist( frame_gray, frame_gray );
|
||||
|
||||
//-- Detect faces
|
||||
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0, Size(80, 80) );
|
||||
//-- Detect faces
|
||||
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0, Size(80, 80) );
|
||||
|
||||
for( size_t i = 0; i < faces.size(); i++ )
|
||||
for( size_t i = 0; i < faces.size(); i++ )
|
||||
{
|
||||
Mat faceROI = frame_gray( faces[i] );
|
||||
std::vector<Rect> eyes;
|
||||
Mat faceROI = frame_gray( faces[i] );
|
||||
std::vector<Rect> eyes;
|
||||
|
||||
//-- In each face, detect eyes
|
||||
eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CASCADE_SCALE_IMAGE, Size(30, 30) );
|
||||
if( eyes.size() == 2)
|
||||
{
|
||||
//-- Draw the face
|
||||
Point center( faces[i].x + faces[i].width/2, faces[i].y + faces[i].height/2 );
|
||||
ellipse( frame, center, Size( faces[i].width/2, faces[i].height/2), 0, 0, 360, Scalar( 255, 0, 0 ), 2, 8, 0 );
|
||||
//-- In each face, detect eyes
|
||||
eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CASCADE_SCALE_IMAGE, Size(30, 30) );
|
||||
if( eyes.size() == 2)
|
||||
{
|
||||
//-- Draw the face
|
||||
Point center( faces[i].x + faces[i].width/2, faces[i].y + faces[i].height/2 );
|
||||
ellipse( frame, center, Size( faces[i].width/2, faces[i].height/2 ), 0, 0, 360, Scalar( 255, 0, 0 ), 2, 8, 0 );
|
||||
|
||||
for( size_t j = 0; j < eyes.size(); j++ )
|
||||
{ //-- Draw the eyes
|
||||
Point eye_center( faces[i].x + eyes[j].x + eyes[j].width/2, faces[i].y + eyes[j].y + eyes[j].height/2 );
|
||||
int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 );
|
||||
circle( frame, eye_center, radius, Scalar( 255, 0, 255 ), 3, 8, 0 );
|
||||
}
|
||||
}
|
||||
for( size_t j = 0; j < eyes.size(); j++ )
|
||||
{ //-- Draw the eyes
|
||||
Point eye_center( faces[i].x + eyes[j].x + eyes[j].width/2, faces[i].y + eyes[j].y + eyes[j].height/2 );
|
||||
int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 );
|
||||
circle( frame, eye_center, radius, Scalar( 255, 0, 255 ), 3, 8, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//-- Show what you got
|
||||
imshow( window_name, frame );
|
||||
//-- Show what you got
|
||||
imshow( window_name, frame );
|
||||
}
|
||||
|
Reference in New Issue
Block a user