Note that there are some explanatory texts on larger screens.

plurals
  1. POhow is PCA implemented on a camera captured image?
    primarykey
    data
    text
    <p>I have successfully implemented face detection part in my Face Recognition project.Now i have a rectangular region of face in an image.Now i have to implement PCA on this detected rectangular region to extract important features.I have used examples of implementing PCA on face databases.I want to know how we can pass our detected face to function implementing PCA?Is it that we pass the rectangle frame? This is the code for my face detection.</p> <pre><code>#include "cv.h" #include "highgui.h" #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;assert.h&gt; #include &lt;math.h&gt; #include &lt;float.h&gt; #include &lt;limits.h&gt; #include &lt;time.h&gt; #include &lt;ctype.h&gt; // Create a string that contains the exact cascade name const char* cascade_name = "haarcascade_frontalface_alt.xml"; /* "haarcascade_profileface.xml";*/ // Function prototype for detecting and drawing an object from an image void detect_and_draw( IplImage* image ); // Main function, defines the entry point for the program. int main( int argc, char** argv ) { // Create a sample image IplImage *img = cvLoadImage("Image018.jpg"); if(!img) { printf("could not load image"); return -1; } // Call the function to detect and draw the face positions detect_and_draw(img); // Wait for user input before quitting the program cvWaitKey(); // Release the image cvReleaseImage(&amp;img); // Destroy the window previously created with filename: "result" cvDestroyWindow("result"); // return 0 to indicate successfull execution of the program return 0; } // Function to detect and draw any faces that is present in an image void detect_and_draw( IplImage* img ) { // Create memory for calculations static CvMemStorage* storage = 0; // Create a new Haar classifier static CvHaarClassifierCascade* cascade = 0; int scale = 1; // Create a new image based on the input image IplImage* temp = cvCreateImage( cvSize(img-&gt;width/scale,img-&gt;height/scale), 8, 3 ); // Create two points to represent the face locations CvPoint pt1, pt2; int i; // Load the HaarClassifierCascade cascade = (CvHaarClassifierCascade*)cvLoad( cascade_name, 0, 0, 0 ); // Check whether the cascade has loaded successfully. Else report and error and quit if( !cascade ) { fprintf( stderr, "ERROR: Could not load classifier cascade\n" ); return; } // Allocate the memory storage storage = cvCreateMemStorage(0); // Create a new named window with title: result cvNamedWindow( "result", 1 ); // Clear the memory storage which was used before cvClearMemStorage( storage ); // Find whether the cascade is loaded, to find the faces. If yes, then: if( cascade ) { // There can be more than one face in an image. So create a growable sequence of faces. // Detect the objects and store them in the sequence CvSeq* faces = cvHaarDetectObjects( img, cascade, storage, 1.1, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(40, 40) ); // Loop the number of faces found. for( i = 0; i &lt; (faces ? faces-&gt;total : 0); i++ ) { // Create a new rectangle for drawing the face CvRect* r = (CvRect*)cvGetSeqElem( faces, i ); // Find the dimensions of the face,and scale it if necessary pt1.x = r-&gt;x*scale; pt2.x = (r-&gt;x+r-&gt;width)*scale; pt1.y = r-&gt;y*scale; pt2.y = (r-&gt;y+r-&gt;height)*scale; // Draw the rectangle in the input image cvRectangle( img, pt1, pt2, CV_RGB(255,0,0), 3, 8, 0 ); } } // Show the image in the window named "result" cvShowImage( "result", img ); // Release the temp image created. cvReleaseImage( &amp;temp ); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload