Você está na página 1de 6

#include<iostream>

#include <stdio.h>
using namespace std;
int main(int argc, char *argv[]){
cout <<"my name is"<<argv[0] << endl;
system ("face.exe Rashid");
system ("PAUSE");
return 0;
}

.
#include<iostream>
#include <stdio.h>
using namespace std;
int main(int argc, char *argv[]){
cout <<"my name is"<<argv[0] << endl;
if(argc>1)
{
cout <<"First Argment is "<<argv[1] << endl;
}
system ("face.exe Rashid");
system ("PAUSE");
return 0;
}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#include<iostream>
#include <stdio.h>
using namespace std;
int main(int argc, char *argv[]){
cout <<"my name is"<<argv[0] << endl;
if(argc>1)
{
cout <<"my name is"<<argv[0] << endl;

}
system ("PAUSE");
return 0;

.
#include<iostream>
#include <stdio.h>
using namespace std;
int main(int argc, char *argv[]){
cout <<"my name is"<<argv[0] << endl;
if(argc>1)
system ("PAUSE");
return 0;
}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#include<iostream>
#include <stdio.h>

using namespace std;


void main(int argc, char *argv){
cout <<"my name is"<<argv[0] << endl;
system ("PAUSE");
}

//////////////////////////////////////////////////
#include<iostream>
#include <stdio.h>
void main(int argc, char *argv){
printf("hello world!");
}

// Face.cpp : Defines the entry point for the console application.


//
#include "stdafx.h"
#include <stdio.h>
#include<conio.h>
#include "cv.h"
#include "highgui.h"
#include "cvaux.h"
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace cv;
using namespace std;
Mat frame;
string extention = ".jpg";
string str_count,username,save;
char *window_name = "Left Click to Take snapshot from WebCam made by Chishti";
int counts;
CvHaarClassifierCascade *cascade;
CvMemStorage
*storage;
char *face_cascade="haarcascade_frontalface_alt2.xml";
void detectFace( IplImage *img,IplImage *temp_img,int img_no)
{
char image[100],msg[100],temp_image[100];
float m[6];
double factor = 1;
IplImage *crop,*sizee;
CvMat M = cvMat( 2, 3, CV_32F, m );
int w = (img)->width;
int h = (img)->height;
CvSeq* faces;
CvRect *r;
m[0] = (float)(factor*cos(0.0));
m[1] = (float)(factor*sin(0.0));
m[2] = w*0.5f;
m[3] = -m[1];
m[4] = m[0];
m[5] = h*0.5f;
cvGetQuadrangleSubPix(img, temp_img, &M);
CvMemStorage* storage=cvCreateMemStorage(0);
cvClearMemStorage( storage );
if( cascade )
faces = cvHaarDetectObjects(img,cascade, storage, 1.2, 2, CV_HAAR_DO_CANNY_PRUNING,
cvSize(20, 20));
else
printf("\nFrontal face cascade not loaded\n");
printf("\n no of faces detected are %d",faces->total);

for(int i = 0 ; i < ( faces ? faces->total : 0 ) ; i++ )


{

r = ( CvRect* )cvGetSeqElem( faces, i );


printf("\n face_x=%d face_y=%d wd=%d ht=%d",r->x,r->y,r->width,r->height);
cvSetImageROI(img,cvRect(r->x, r->y, r->width, r->height));
crop = cvCreateImage(cvGetSize(img), img->depth, img->nChannels);
cvCopy(img, crop, NULL);
//cvShowImage(crops,crop);
cvResetImageROI(img);
CvSize
ss = cvSize( 300, 300);
sizee = cvCreateImage(ss, crop->depth, crop->nChannels);
cvResize(crop, sizee);
}
if(faces->total>0)
{
//sprintf(image,"C:\\Users\\USMAN\\Documents\\Visual Studio
2010\\Projects\\Speaker14\\Speaker\\bin\\Debug\\%s%d.jpg",username,img_no);
sprintf(image,"%s%d.jpg",username,img_no);
cvSaveImage(image, sizee );
}
}
void my_mouse_callback(int event, int x, int y, int flags, void* param) {

if ( event == CV_EVENT_LBUTTONDOWN){
counts++;
char buffer[33];
_itoa(counts,buffer,10);
str_count = buffer;
save = username+str_count+extention;
//save = str_count+extention;
if(imwrite(save.c_str(), frame)==1)
cout <<"Your Picture is saved as :"<< save <<endl;
else
cout <<"Error: Picture can not be saved"<< save <<endl;

}
}
int main( int argc, char *argv[] )
{
username = argv[1];
cout <<"username is:"<<username << endl;
CvCapture *capture;
IplImage *img,*temp_img;
int
key;
counts=0;
char image[100],crops[100],temp_image[100];

all \n";

VideoCapture cap(0);
if(!cap.isOpened()) {
cout <<"Error: Some other softwre is using that camera or there is no camera at
system("pause");
return -1;

}
namedWindow(window_name,1);
cvSetMouseCallback( window_name, my_mouse_callback);
for (;counts<7;)
{
cap >> frame;
// cvtColor(frame, edges, CV_BGR2GRAY);
imshow(window_name, frame);
if(waitKey(30) >= 0) break;
}
cap.release();
/* load the classifier
note that I put the file in the same directory with
this code */
storage = cvCreateMemStorage( 0 );
cascade = ( CvHaarClassifierCascade* )cvLoad( face_cascade, 0, 0, 0 );

if( !(cascade) )
{
fprintf( stderr, "ERROR: Could not load classifier cascade\n" );
return -1;
}
for(int j=1;j<8;j++)
{

int test[25]={},k=0,l;
//char a[25]="This is a test string.";
while(username[k]!='\0') {test[k]=username[k]; k++;}
for(l=0;l<k-1;l++) printf("%d ",test[l]);
sprintf(image,"C:\\Users\\USMAN\\Documents\\Visual Studio
2010\\Projects\\Speaker14\\Speaker\\bin\\Debug\\%d%d.jpg",test,j);
//sprintf(image,"%s%d.jpg",username,j);
img=cvLoadImage(image);
temp_img=cvLoadImage(image);
if(!img)
{
printf("Could not load image file and trying once again: %s\n",image);
}
printf("\n curr_image = %s",image);
detectFace(img,temp_img,j);
}
cvReleaseHaarClassifierCascade( &cascade );
cvReleaseMemStorage( &storage );

cvReleaseImage(&img);
cvReleaseImage(&temp_img);
system("PAUSE");
return 0;
}

Você também pode gostar