Ask Your Question

Josiah's profile - activity

2017-03-20 15:42:17 -0600 received badge  Taxonomist
2012-10-01 14:56:17 -0600 asked a question System.Runtime.InteropServices.SEHException

I created a simple windows form application of OpenCV that captures stream of images from a webcam and detect the face and then display the image to a picture box. I created a separate thread to execute the face detector function. The form has a button and picture box and when the button is pressed, the face detector thread starts. It works fine for approximately 2 and half minutes and then it throws this exception:

"An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in Sampleapp.exe

Additional information: External component has thrown an exception."

Here is the entire code for the face detector function:


#include "stdafx.h"
#include "Form1.h"
#include <cv.h>
#include <highgui.h>

namespace Sampleapp {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;

    const char *frontalface_cascade_name = "haarcascade_frontalface_alt.xml";
    CvHaarClassifierCascade *frontalface_cascade;
    //----------------------
    // Face detector
    void Form1::face_detector()
    {
        IplImage* img;
        IplImage *img_gray;
        CvMemStorage *storage;
        CvSeq* faces;
        /*CvSeq* righteye;
        CvSeq* lefteye;
        CvSeq* nose;*/
        frontalface_cascade = ( CvHaarClassifierCascade* )cvLoad( frontalface_cascade_name, 0, 0, 0 );
        while(this->button1->Text == "no")
        {
            try             
            {
                storage = cvCreateMemStorage( 0 );
                CvCapture *capture = cvCreateCameraCapture(0);
                img = cvQueryFrame(capture);
                img_gray = cvCreateImage( cvSize( img->width, img->height ), IPL_DEPTH_8U, 1 );
                cvCvtColor( img, img_gray, CV_BGR2GRAY );
                cvEqualizeHist( img_gray, img_gray );
                faces = cvHaarDetectObjects( img_gray, frontalface_cascade, storage, 1.1, 2, CV_HAAR_FIND_BIGGEST_OBJECT, cvSize(40, 40));
                this->pictureBox1->Image = (gcnew System::Drawing::Bitmap(img->width,img->height,img->widthStep, System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr)img->imageData));                            
                cvReleaseMemStorage(&storage);
            }
            catch (System::NullReferenceException^ m)
            {
            }
        }
    }
}

The exception is thrown at:

faces = cvHaarDetectObjects( .....)
segment.

If anyone has any idea what I should to solve this problem, please let me know.

Sincerely, Josiah

2012-09-11 12:59:38 -0600 commented answer Conversion between IplImage and MxArray

Thanks for you suggestion, I solved the problem. I used cvGetRawData(img, (uchar**)&data) function from this link: http://tech.groups.yahoo.com/group/OpenCV/message/72042

2012-09-04 18:52:06 -0600 asked a question implementation of feature selection using adaboost

I am currently working on facial expression recognition using Matlab and I use Gabor filter banks to extract features from each training images. Since the features are too many to be used for classification, I needed to implement Adaboost feature selection to select only the important features and then use the selected features to train an SVM classifier. I have found sample implementations of Adaboost classification but not feature selection. If anyone has any idea of how to implement Adaboost feature selection or has an already implemented code that I can refer, please let me know.

Sincerely,

2012-07-18 01:07:11 -0600 received badge  Popular Question (source)
2012-07-17 18:22:43 -0600 received badge  Student (source)
2012-07-17 14:02:55 -0600 asked a question Conversion between IplImage and MxArray

I am working on a project that accepts stream of images from a webcam through CvCapture, detect the face of the user through cvHaarDetectObjects() from each image and then send the image and its detected face locations to Matlab through Matlab engine. Then it will further be processed in Matlab. So my problem is how I can convert the Iplimage(gray-scale) of the detected face to MxArray variable and pass it as a 2D matrix to the Matlab through the Matlab engine. If anyone has any idea, please let me know.

Sincerely,

2012-07-17 14:00:32 -0600 asked a question Conversion between Iplimage and MxArray

I am working on a project that accepts stream of images from a webcam through CvCapture, detect the face of the user through cvHaarDetectObjects() from each image and then send the image and its detected face locations to Matlab through Matlab engine. Then it will further be processed in Matlab. So my problem is how I can convert the Iplimage(gray-scale) of the detected face to MxArray variable and pass it as a 2D matrix to the Matlab through the Matlab engine. If anyone has any idea, please let me know.

Sincerely,