Find the answer to your Linux question:
Results 1 to 3 of 3
I want to make a Visual Studio file into a Linux executable file. It functions appropriately compiled with Visual Studio to create an executable file for Windows. But I have ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2013
    Posts
    4

    want to copy face detection file I use in Visual Studio to Linux


    I want to make a Visual Studio file into a Linux executable file.
    It functions appropriately compiled with Visual Studio to create an executable file for Windows.

    But I have used this in localhost for some time and now I want to take it to the server which runs CentOS 6.3
    and on which I have installed OpenCV

    Still I'm unsure whether it actually should work.

    Code:
    #include "stdafx.h"
    #include <stdio.h>
    #include<conio.h>
    #include "cv.h"
    #include "highgui.h"
    #include "cvaux.h"
    
    CvHaarClassifierCascade *cascade,*cascade_e,*cascade_nose,*cascade_mouth;
    CvMemStorage            *storage;
    char *face_cascade="haarcascade_frontalface_alt2.xml";
    
    void detectFacialFeatures( IplImage *img,IplImage *temp_img,int img_no)
    {
        
        char image[100],msg[100],temp_image[100];
        float m[6];
        double factor = 1;
        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 );
            cvRectangle( img,cvPoint( r->x, r->y ),cvPoint( r->x + r->width, r->y + r->height ),
                         CV_RGB( 255, 0, 0 ), 1, 8, 0 );    
        
            printf("\n face_x=%d face_y=%d wd=%d ht=%d",r->x,r->y,r->width,r->height);
            
          
        
            cvResetImageROI(img);
    
        }
     
          cvResetImageROI(img);
    
          if(faces->total>0)
            {
                sprintf(image,"face_output%d.jpg",img_no);
                cvSaveImage( image, img );
            }
    }
    
    int main( int argc, char** argv )
    {
        CvCapture *capture;
        IplImage  *img,*temp_img;
        int       key;
    
        char image[100],temp_image[100];
        
    
        storage = cvCreateMemStorage( 0 );
            cascade = ( CvHaarClassifierCascade* )cvLoad( face_cascade, 0, 0, 0 );
        
        if( !(cascade) )
            {
            fprintf( stderr, "ERROR: Could not load classifier cascade\n" );
            return -1;
            }
        
    
    
             sprintf(image,"dimage%d.jpg",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);
          
            detectFacialFeatures(img,temp_img,j);
      
    
        cvReleaseHaarClassifierCascade( &cascade );
        cvReleaseMemStorage( &storage );
        
         cvReleaseImage(&img);
         cvReleaseImage(&temp_img);
        
    
        return 0;
    }
    If I save that as myfile.c and execute with ssh I see plenty of errors.

  2. #2
    Linux Guru
    Join Date
    Oct 2007
    Location
    Tucson AZ
    Posts
    3,190
    If I save that as myfile.c and execute with ssh I see plenty of errors.
    Do you compile and make it executable? Unfortunately, members here who might be able to help you can't see these errrors as you neglected to post any. That would be a start.

  3. #3
    Just Joined!
    Join Date
    Mar 2013
    Posts
    4
    Quote Originally Posted by yancek View Post
    Do you compile and make it executable? Unfortunately, members here who might be able to help you can't see these errrors as you neglected to post any. That would be a start.
    Yes, true.

    This is all I do plus the output with errors.

    Code:
         [root@ip-xxx c]# ./facedetect.c
         ./facedetect.c: line 5: CvHaarClassifierCascade: command not found
         ./facedetect.c: line 6: CvMemStorage: command not found
         ./facedetect.c: line 8: syntax error near unexpected token `('
         ./facedetect.c: line 8: `void detectfaces(IplImage *frame)'

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •