project1.exe中0x52f9e470处未处理的异常:0xC000001D:非法指令 [英] Unhandled exception at 0x52f9e470 in project1.exe : 0xC000001D : Illegal instruction
问题描述
我正在尝试使用c ++中的opencv检测对象,但出现错误: 在project1.exe中0x52f9e470处出现未处理的异常:0xC000001D:非法指令.
i am trying to detect an object using opencv in c++ but i am getting an error : Unhandled exception at 0x52f9e470 in project1.exe : 0xC000001D : Illegal instruction.
使用Windows 7 32位,opencv 2.4.3,Visual Studio(C ++)2010,我的代码是:
using windows 7 32 bit,opencv 2.4.3,visual studio (c++) 2010 and my code is :
#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
// Create a string that contains the exact cascade name
// Contains the trained classifer for detecting hand
const char *cascade_name="D:/31dec12/hand.xml";
//The function detects the hand from input frame and draws a rectangle around the detected portion of the frame
void detect_and_draw( IplImage* img )
{
// Create memory for calculations
static CvMemStorage* storage = 0;
// Create a new Haar classifier
static CvHaarClassifierCascade* cascade = 0;
// Sets the scale with which the rectangle is drawn with
int scale = 1;
// Create two points to represent the hand locations
CvPoint pt1, pt2;
// Looping variable
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 hands. If yes, then:
if( cascade )
{
// There can be more than one hand in an image. So create a growable sequence of hands.
// Detect the objects and store them in the sequence
CvSeq* hands = cvHaarDetectObjects( img, cascade, storage,
1.1, 2, CV_HAAR_DO_CANNY_PRUNING,
cvSize(40, 40) );
// Loop the number of hands found.
for( i = 0; i < (hands ? hands->total : 0); i++ )
{
// Create a new rectangle for drawing the hand
CvRect* r = (CvRect*)cvGetSeqElem( hands, i );
// Find the dimensions of the hand,and scale it if necessary
pt1.x = r->x*scale;
pt2.x = (r->x+r->width)*scale;
pt1.y = r->y*scale;
pt2.y = (r->y+r->height)*scale;
// Draw the rectangle in the input image
cvRectangle( img, pt1, pt2, CV_RGB(230,20,232), 3, 8, 0 );
}
}
// Show the image in the window named "result"
cvShowImage( "result", img );
}
// A Simple Camera Capture Framework
int main()
{
// Gets the input video stream from camera
CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
// Checks if the input stream is obtained
if( !capture )
{
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}
// Show the image captured from the camera in the window and repeat
while( 1 )
{
// Get one frame
IplImage* frame = cvQueryFrame( capture );
// Cecks if a frame is obtained
if( !frame )
{
fprintf( stderr, "ERROR: frame is null...\n" );
getchar();
break;
}
// Flips the frame into mirror image
cvFlip(frame,frame,1);
// Call the function to detect and draw the hand positions
detect_and_draw(frame);
//If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
//remove higher bits using AND operator
if( (cvWaitKey(10) & 255) == 27 )
break;
}
// Release the capture device housekeeping
cvReleaseCapture( &capture );
return 0;
}
推荐答案
您使用的是哪种CPU?上次出现错误:0xC000001D:非法指令与代码中使用的SSE指令有关.某些新的SSE指令未在AMD处理器上实现,例如因此,您可以通过在没有SSE支持的情况下重建opencv来解决此问题.
What kind of cpu are you using? Last time I had the error: 0xC000001D : Illegal instruction was related to the SSE instruction used in the code. Some new SSE instruction are not implemented at AMD processors e.g. So you can fix this by rebuilding opencv without SSE support.
这篇关于project1.exe中0x52f9e470处未处理的异常:0xC000001D:非法指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!