| re: Segmentation Fault : Delete[]
I have got the segmentation fault problem and I am wondering if anyone can help me.
Firstly I'm developed in C++ on a Linux machine (using g++ compiler).
I am going to develop the Visual Surveillance application using the Network Camera as a hardware.
Program No. 1:
if (mysql_query(conn, "truncate video")) {
//fprintf(stderr, "%s\n", mysql_error(conn));
// exit(0);
}
/* end of MySQL */
if(argc>1){
long current=0;
CURL *curl;
char filename[200];
sprintf(filename,"temp%d.jpg",videoNumber);
FILE *file;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
char buf[200];
//printf("Test %s\n",inpFile);
if(strlen(inpFile)==2)
{
if(curl){
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
/* get the first document */
sprintf(buf,"http://root:amol@1234@172.21.107.207/axis-cgi/jpg/image.cgi?resolution=320x240");
curl_easy_setopt(curl, CURLOPT_URL,buf);
int i=0;
CallAR.CallBackActivityReco(inpFile,dumpDir,doorfi le,videoNumber);
while(!signaled){
file=fopen(filename,"w");
curl_easy_setopt(curl,CURLOPT_WRITEDATA,file);
curl_easy_perform(curl);
fclose(file);
//printf("Test\n");
IplImage *NtwkImage=cvLoadImage(filename,1);
current++;
char buffer[50];
sprintf(buffer,"dumpDir/%010d.jpg",current);
//printf("Test\n");
if(!CallAR.frame_call(inpFile,dumpDir,NtwkImage,co nn,videoNumber)) break;
cvReleaseImage(&NtwkImage);
}
curl_easy_cleanup(curl);
}
}
else{
CallAR.CallBackActivityReco(inpFile,dumpDir,doorfi le,videoNumber);
IplImage* I=0;
while(!signaled){
if(!CallAR.frame_call(inpFile,dumpDir,I,conn,video Number)) break;
}
}
exit(0);
}
return 0;
}
and
Program No. 2:
int CallBackAR::frame_call(char* inpFile, char* dumpDir,IplImage* NtwkImage,MYSQL *conn,int vno){
//printf("TESTING\n");
timeval tim;
double t1,t2;
if(strlen(inpFile)==1)
{
gettimeofday(&tim, NULL);
t1=tim.tv_sec+(tim.tv_usec/1000000.0);
image = useStreamer();
gettimeofday(&tim, NULL);
t2=tim.tv_sec+(tim.tv_usec/1000000.0);
//printf("%.6lf Before Grab Time\n", t1);
//printf("%.6lf After Grab time\n", t2);
}
else if(strlen(inpFile)==2)
{
gettimeofday(&tim, NULL);
t1=tim.tv_sec+(tim.tv_usec/1000000.0);
image=NtwkImage;
//pthread_mutex_lock (&mutexsum);
//image=cvLoadImage("image.cgi?resolution=320x240",1 );
//pthread_mutex_unlock (&mutexsum);
gettimeofday(&tim, NULL);
t2=tim.tv_sec+(tim.tv_usec/1000000.0);
//printf("%.6lf Before Grab Time\n", t1);
//printf("%.6lf After Grab time\n", t2);
}
else{
gettimeofday(&tim, NULL);
t1=tim.tv_sec+(tim.tv_usec/1000000.0);
if( !cvGrabFrame( capture )) return 0;
cimage = cvRetrieveFrame(capture);
gettimeofday(&tim, NULL);
t2=tim.tv_sec+(tim.tv_usec/1000000.0);
//printf("%.6lf Before Grab Time\n", t1);
//printf("%.6lf After Grab time\n", t2);
cvResize(cimage,image);
}
Please help me as early as possible since I have solve this issue today.
|