Question

error!

Asked by: gen12324

Hi, right now i'm testing motion tracker with optical flow. When i run it, it appears to have error.
How should i solve it? I'm new to c++

First-chance exception at 0x00411b98 in Motion Tracker with Optical Flow.exe: 0xC0000005: Access violation writing location 0x02ba9000.
Unhandled exception at 0x00411b98 in Motion Tracker with Optical Flow.exe: 0xC0000005: Access violation writing location 0x02ba9000.
The program '[1540] Motion Tracker with Optical Flow.exe: Native' has exited with code 0 (0x0).

// Motion Tracker with Optical Flow.cpp : Defines the entry point for the console application.
//
 
#include <stdafx.h>
#include <cv.h>
#include <highgui.h>
#include <math.h>
#include <stdio.h>
 
 
const int MAX_COUNT = 2000;
int count = 0, startOfTrackPoints = 0;
 
CvPoint2D32f* points[2] = {0,0};
 
IplImage *color_img=0;
 
/* Listener for mouse clicks */
void OnMouseClick(int event, int x, int y, int flags, void* param)
{
	    
	if(color_img->origin)
	y = color_img->height - y;
	if(event == CV_EVENT_LBUTTONDOWN && count < MAX_COUNT) 
	{
		// Add point
		points[1][count] = points[0][count] = cvPoint2D32f(x, y); 
		count++;
	}
	
}
int main(int argc,char *argv[])
{
	
	int c, i, j, step, win_size, flags, color;
	char* status = 0;
 
	CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
	if( !capture ) 
	{
    fprintf( stderr, "ERROR: capture is NULL \n" );
    getchar();
    return -1;
	}
printf("Debug 1\n");
	IplImage *gray_img, *prev_img, *curr_img;
	IplImage *pyramid, *prev_pyramid, *optical_flow_field;
	CvPoint p1, p2, p3, p4, p5;
	printf("Welcome to Ax demo! ^_^\n");
	printf("Click on the 'This is my webcam!' window to add trackballs.\n");
	printf("The 'Field' window shows the optical flow with larger \n");
	printf("arrows corresponding to larger displacements.\n\n");
	printf("Keyboard commands:\n");
	printf(" ESC to quit\n");
	printf(" c to clear all the trackballs\n");
	printf(" n to cycle through the different trackball colors\n");
 
/* Initialization and space allocation */
color_img = cvQueryFrame(capture);
if(!color_img)
return 0;
 
gray_img = cvCreateImage(cvSize(color_img->width,color_img->height), IPL_DEPTH_8U, 1);
optical_flow_field = cvCreateImage( cvSize(color_img->width,color_img->height), IPL_DEPTH_8U, 1);
prev_img = cvCreateImage(cvSize(color_img->width,color_img->height), IPL_DEPTH_8U, 1);
curr_img = cvCreateImage(cvSize(color_img->width,color_img->height), IPL_DEPTH_8U, 1);
pyramid = cvCreateImage(cvSize(color_img->width,color_img->height), IPL_DEPTH_8U, 1);
prev_pyramid = cvCreateImage(cvSize(color_img->width,color_img->height), IPL_DEPTH_8U, 1);
 
gray_img->origin = color_img->origin;
optical_flow_field->origin = color_img->origin;
prev_img->origin = color_img->origin;
curr_img->origin = color_img->origin;
pyramid->origin = color_img->origin;
prev_pyramid->origin = color_img->origin;
 
	points[0] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(points[0][0]));
	points[1] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(points[0][0]));
	status = (char*)cvAlloc(MAX_COUNT);
	flags = 0;
	step = 10;
	win_size = 10;
	color = 0;
	
 
/* Create windows */
cvNamedWindow("This is my webcam!", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Field", CV_WINDOW_AUTOSIZE);
 
/* Set up mouse event listener */
int mouseParam=5;
cvSetMouseCallback("This is my webcam!", OnMouseClick, &mouseParam);
 
/* Initialize the points to the points on the image separated
by distances of 10 pixels */
printf("Debug 2\n");
for(i = 0; i < color_img->height; i+=step) 
{
	for(j = 0; j < color_img->width; j+=step) 
	{
		points[0][count] = cvPoint2D32f(j, i);
		points[1][count] = cvPoint2D32f(j, i);
		count++; // count the number of points
		
	}
 
 
}
 
/* Where track points begin */
startOfTrackPoints = count;
 
/* Use the "first" frame */
color_img = cvQueryFrame(capture);
if(!color_img)
return 0;
 
cvCvtColor( color_img, gray_img, CV_BGR2GRAY );
 
/* Smooth to improve accuracy */
cvSmooth(gray_img, gray_img, CV_GAUSSIAN, 3, 0, 0);
cvSmooth(gray_img, gray_img, CV_GAUSSIAN, 3, 0, 0);
cvSmooth(gray_img, gray_img, CV_GAUSSIAN, 3, 0, 0);
cvCopy(curr_img, prev_img, 0);
cvCopy(gray_img, curr_img, 0);
 
/* Begin the main infinite loop until break */
for(;;) 
{
	color_img = cvQueryFrame(capture);
	if(!color_img)
	break;
	cvCvtColor( color_img, gray_img, CV_BGR2GRAY );
 
	/* Smooth to improve accuracy */
	cvSmooth(gray_img, gray_img, CV_GAUSSIAN, 3, 0, 0);
	cvSmooth(gray_img, gray_img, CV_GAUSSIAN, 3, 0, 0);
	cvSmooth(gray_img, gray_img, CV_GAUSSIAN, 3, 0, 0);
	cvCopy(curr_img, prev_img, 0);
	cvCopy(gray_img, curr_img, 0);
	cvCopy(pyramid, prev_pyramid, 0);
 
	for(i = startOfTrackPoints; i < count; i++)
	points[0][i] = points[1][i];
 
	/* Calculate the optical flow using pyramidal iterative LK */
	cvCalcOpticalFlowPyrLK(prev_img, curr_img, prev_pyramid, pyramid,
	points[0], points[1], count, cvSize(win_size, win_size), 3, status, 0,
	cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03), flags);
 
	/* Threshold to ignore noise */
	for(i = startOfTrackPoints; i < count; i++)
	if(abs((int)(points[0][i].x - points[1][i].x)) > 50 ||
	abs((int)(points[0][i].y - points[1][i].y)) > 50)
	points[1][i] = points[0][i];
 
	/* Set flags */
	flags |= CV_LKFLOW_PYR_A_READY;
 
	/* Refresh the optical flow field */
	for (i = 0; i < optical_flow_field->height; i++)
	for (j = 0; j < optical_flow_field->width; j++)
	(optical_flow_field->imageData + optical_flow_field->widthStep*i)[j] = (char)255;
 
	/* Draw the optical flow field; the greater the velocity, the bigger the
	respective arrow and arrowhead will be for better visualization */
 
for (i = 0; i < startOfTrackPoints; i++) 
{
	/* Threshold velocities: not drawing very small or very large velocities */
	if((abs((int)(points[0][i].x - points[1][i].x)) >= 1 ||
	abs((int)(points[0][i].y - points[1][i].y)) >= 1) &&
	(abs((int)(points[0][i].x - points[1][i].x)) <= 20 &&
	abs((int)(points[0][i].y - points[1][i].y)) <= 20)) 
	{
 
		/* Arrow */
		cvLine(optical_flow_field, cvPointFrom32f(points[0][i]),
		cvPointFrom32f(points[1][i]), cvScalar(0, 0, 0,0), 1, 8, 0);
		/* Arrowhead */
 
		p1 = cvPoint((int)(cvPointFrom32f(points[0][i]).x + 0.7*(cvPointFrom32f(points[1][i]).x - cvPointFrom32f(points[0][i]).x)),
		(int)(cvPointFrom32f(points[0][i]).y + 0.7*(cvPointFrom32f(points[1][i]).y -
		cvPointFrom32f(points[0][i]).y)));
 
		p2 = cvPoint((int)(cvPointFrom32f(points[0][i]).x + 0.7*(cvPointFrom32f(points[1][i]).x -
		cvPointFrom32f(points[0][i]).x)),
		(int)cvPointFrom32f(points[1][i]).y);
 
		p3 = cvPoint((int)cvPointFrom32f(points[1][i]).x,(int)(cvPointFrom32f(points[0][i]).y +
		0.7*(cvPointFrom32f(points[1][i]).y - cvPointFrom32f(points[0][i]).y)));
 
		p4 = cvPoint((int)(p1.x + 0.5*(p2.x-p1.x)),
		(int)(p1.y + 0.5*(p2.y-p1.y)));
 
		p5 = cvPoint((int)(p1.x + 0.5*(p3.x-p1.x)),
		(int)(p1.y + 0.5*(p3.y-p1.y)));
 
		cvLine(optical_flow_field, cvPointFrom32f(points[1][i]),
		p4, cvScalar(0, 0, 0,0), 1, 8, 0);
 
		cvLine(optical_flow_field, cvPointFrom32f(points[1][i]),
		p5, cvScalar(0, 0, 0,0), 1, 8, 0);
	}
 
	else 
	{
		/* Draws a dot */
		cvLine(optical_flow_field, cvPointFrom32f(points[0][i]),
		cvPointFrom32f(points[0][i]), cvScalar(0, 0, 0,0), 1, 8, 0);
	}
 
}
 
for(i = startOfTrackPoints; i < count; i++) 
{
	/* Draw trackballs */
	if(color == 0)
	cvCircle(color_img, cvPoint((int)points[1][i].x, (int)points[1][i].y),
	5, cvScalar(0,255,0,0), 3, 8, 0);
 
	else if(color == 1)
	cvCircle(color_img, cvPoint((int)points[1][i].x, (int)points[1][i].y),
	5, cvScalar(255,0,0,0), 3, 8, 0);
 
	else
	cvCircle(color_img, cvPoint((int)points[1][i].x, (int)points[1][i].y), 5, cvScalar(0,255,255,0), 3, 8, 0);
}
 
	/* Show images */
	cvShowImage("This is my webcam!", color_img);
	cvShowImage("Field", optical_flow_field);
	/* Wait */
	c = cvWaitKey(10);
	/* Check for ESC */
if(c == 27)
break;
 
else if(c == 'c')
startOfTrackPoints = count;
 
else if(c == 'n') 
{
	color++;
	color = color % 3;
	}
}
	/* Release windows */
	cvReleaseCapture(&capture);
	cvDestroyWindow("This is my webcam!");
	cvDestroyWindow("Field");
}

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-08-06 at 18:44:11ID24633586
Topics

C++ Programming Language

,

Open Source Programming

,

C++ Builder

Participating Experts
2
Points
500
Comments
25

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. motion_jpeg decoder
    hi! where can I find the motion_jpeg decoder or information about it ? thanks.
  2. VB video in + motion tracker
    Hello I would like to know how to add video (avi or live) into VB and have the ability (if needed) to do some motion tracking or motion detection. I'm new into this, so I need the specifics first, like what components I need to add the video first... start/stop video... the...
  3. Motion Detection
    Hi, I have a webcam and written a program in VB6 which takes frames from it. Now I´m interested in programming relatively good motion detection. I tried it with saving two pictures as byte- arrays and compare them, but the problem was, that a lot of pixels are differently wi...
  4. Debugging error - Win32 application - Unhandled Except…
    Hello I am trying to run my code, its compling without errors but when I run it, it gives this runtime unhandled exception, shown below, My code is just a simple code, where it reads some data from a file and stores in a vector and then searches in it and prints it on the s...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: peprPosted on 2009-08-07 at 00:40:41ID: 25040559

This often means accessing the memory via uninitialized pointer. I suspect the initialization lines 77 and 78 (at least), namely the

      points[0] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(points[0][0]));

Firstly sizeof() should be considered a static operation. Next, the points[0][0] means accessing the first element of memory that is pointed to via points[0]. But the points[0] was not initialized, yet. In other words, it is "accessing memory via NULL pointer".

 

by: gen12324Posted on 2009-08-07 at 00:50:40ID: 25040588

Oic. I guess i got that error too. So how should i solve it?

 

by: gen12324Posted on 2009-08-07 at 00:59:45ID: 25040622

By the way, what do you mean by static operation?

 

by: peprPosted on 2009-08-07 at 01:19:15ID: 25040701

As the points should be array of pointers, the allocated memory should be big enough to store the pointers. You want to allocate the space for MAX_COUNT pointers. This means that you multiply the MAX_COUNT by the size of space needed for storing a single pointer. The space for storing a single pointer to the object of "theType" is sizeof(theType*).

However, space for storing a pointer is always independent on the pointed type. This way, you can also write

points[0] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(void*));

By static operation here I mean that the sizeof(void*) is evaluated during the compilation. Depending on the target operating system, it is 4 bytes (32bit OS), or 8 bytes (64bit OS).

 

by: gen12324Posted on 2009-08-07 at 01:51:16ID: 25040861

Wow this is really hard to understand. Anyway i'm using win xp. And my harddisk is left only 100mb.

 

by: gen12324Posted on 2009-08-07 at 02:01:09ID: 25040922

Hi, i still got error.

When i click on the output view, it shows this error:

First-chance exception at 0x00411b28 in Motion Tracker with Optical Flow.exe: 0xC0000005: Access violation writing location 0x02401000.
Unhandled exception at 0x00411b28 in Motion Tracker with Optical Flow.exe: 0xC0000005: Access violation writing location 0x02401000.


The program '[3456] Motion Tracker with Optical Flow.exe: Native' has exited with code 0 (0x0).

 

by: peprPosted on 2009-08-07 at 03:04:37ID: 25041236

Working with pointers does not depend on a concrete OS, nor on the disk size. This is also completely unrelated to OpenCV. By the way, I do not use OpenCV at all, so I can give you some general hints related to C++. To simplify the command, you could use:

    point[0] = cvAlloc(8000);

i.e. allocate 8000 bytes of memory and give me back the pointer to that memory space (the address of the first byte). However, compiler would complain as the cvAlloc() returns the void pointer -- pointer to the void type. This should be mentally interpreted as "pointer to any type". However, the point[0] is declared as pointer to CvPoint2D32f. This way you have to convert the returned type or using the older, C syntax...

    point[0] = (CvPoint2D32f*)cvAlloc(8000);

or using the newer C++ syntax

    point[0] = static_cast<CvPoint2D32f*>(cvAlloc(8000));

Now, you may sometimes want to change the MAX_COUNT. This way the 8000 is not that much visible to say that it is related. Because of that the 8000 is replaced by the

    point[0] = (CvPoint2D32f*)cvAlloc(MAX_COUNT * 4);

Here you assume that the single pointer consumes 4 bytes. However, it may happen one day that you switch to the 64bit target executable. Then your code would be incorrect. Technically, the 4 bytes are just enough to store one pointer value. Logically, the 4 on its own says nothing related to pointers. This way it is better to write the 4 as sizeof(void*) which means "that many bytes that are enough for storing a pointer" -- and it will work also for 64bit case because then sizeof(void*) would be 8 instead.

For the error, you may have some problem with pointer again. However, it may be difficult to spot the place where it happens unless you have some more detailed info. Try to debug your application.

 

by: peprPosted on 2009-08-07 at 03:06:32ID: 25041244

I suggest to store your source for capturing your ideas and try to simplify the code until you get some simpler but working functionality. Then add the features in subsequent steps.

 

by: gen12324Posted on 2009-08-07 at 11:08:36ID: 25045432

Sorry pepr. Application as in win32 console? By the way, i do not seems to have an application. The moment i open new project, i choose win32. There's no button control or radio control.

 

by: peprPosted on 2009-08-07 at 15:45:05ID: 25047453

Well, call it a program if you wish. I am not that good in English. A console program differs from a windowing program only in human interface: one is using textual interface, the othe graphical interface. This is not the core of your problem.

Your problem is that you have quite a lot of code and you do not know where the bug is. I do not know how you got the source, if you wrote if from scratch, or if you got some other application, some skeleton or like that. Definitely, the problem with accessing memory is not related to the human interface (textual or graphic).

Basically, you may try to debug, you may try to look at the code to understand what each line exactly means, you may try to comment-out some parts of the code to find where the bug is. Unfortunately, you probably should learn the basics (like what the pointer is and how it is implemented) if you want to understand what happens in your code.

 

by: itsmeandnobodyelsePosted on 2009-08-08 at 03:19:11ID: 25049104

>>>>      points[0] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(points[0][0]));

Change it to

   points[0] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(CvPoint2D32f));
   points[1] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(CvPoint2D32f));

If it still crashes, goto menu Debug - Exceptions - Win32 Exceptions  and check the c0000005 Access violation to get a break if the exception was thrown.

That way you'll get the exact line where the access violation happened (look at call stack).

Note, the count variable is a global variable initialized to zero. But I couldn't see any statement where it was reset to 0 after use. So, your prog has one shot and after, it probably will crash.

 

by: gen12324Posted on 2009-08-09 at 19:41:35ID: 25056864

itsmeandnobodyelse and pepr::

Sorry for late reply. As i got high fever this few days so i'm unable to reply you .

 

by: gen12324Posted on 2009-08-10 at 02:52:12ID: 25058365

itsmeandnobodyelse:

i have already changed this:

 points[0] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(CvPoint2D32f));
 points[1] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(CvPoint2D32f));

and i also change the settings already. This is the line of errors i having problems with..

for(i = 0; i < color_img->height; i+=step) 
{
	for(j = 0; j < color_img->width; j+=step) 
	{
		points[0][count] = cvPoint2D32f(j, i);
		points[1][count] = cvPoint2D32f(j, i);
		count++; // count the number of points
		
	}
 
 
}
 
/* Where track points begin */
startOfTrackPoints = count;

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:

Select allOpen in new window

 

by: gen12324Posted on 2009-08-11 at 19:07:25ID: 25075183

hi itsmeandnobodyelse:

can you help me on this question? i still got error on the above of the code.

====>>>That way you'll get the exact line where the access violation happened (look at call stack).
I already posted it. from line 5 to line 7

 

by: gen12324Posted on 2009-08-12 at 21:09:50ID: 25085380

looking for itsmeandnobodyelse:

still having this error

 

by: gen12324Posted on 2009-08-12 at 21:12:00ID: 25085386

looking for itsmeandnobodyelse:

From the code above(last second reply), it shows that i having error at that line.

Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\sysfer.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\netapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\secur32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\Program Files\OpenCV\bin\cv110.dll', no matching symbolic information found.
Loaded 'C:\Program Files\OpenCV\bin\cxcore110.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.1433_x-ww_5cf844d2\msvcr80.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.OpenMP_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6c18549a\vcomp.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.1433_x-ww_5cf844d2\msvcp80.dll', no matching symbolic information found.
Loaded 'C:\Program Files\OpenCV\bin\highgui110.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comctl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\avifil32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\winmm.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ole32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msacm32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvfw32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\shell32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\shlwapi.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\avicap32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\oleaut32.dll', no matching symbolic information found.
Loaded 'C:\Program Files\WiT\bin\ippcv-5.1.dll', no matching symbolic information found.
Loaded 'C:\Program Files\WiT\bin\ippcore-5.1.dll', no matching symbolic information found.
Loaded 'C:\Program Files\WiT\bin\libguide40.dll', no matching symbolic information found.
Loaded 'C:\Program Files\WiT\bin\ippcvt7-5.1.dll', no matching symbolic information found.
Loaded 'C:\Program Files\WiT\bin\ippi-5.1.dll', no matching symbolic information found.
Loaded 'C:\Program Files\WiT\bin\ippit7-5.1.dll', no matching symbolic information found.
Loaded 'C:\Program Files\WiT\bin\ipps-5.1.dll', no matching symbolic information found.
Loaded 'C:\Program Files\WiT\bin\ippst7-5.1.dll', no matching symbolic information found.
Loaded 'C:\Program Files\WiT\bin\ippcc-5.1.dll', no matching symbolic information found.
Loaded 'C:\Program Files\WiT\bin\ippcct7-5.1.dll', no matching symbolic information found.
Loaded symbols for 'C:\WINDOWS\system32\Syncor11.dll'
Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\clbcatq.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comres.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\devenum.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\setupapi.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wintrust.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\crypt32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msasn1.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\imagehlp.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msdmo.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\qcap.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\quartz.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\uxtheme.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ksproxy.ax', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ksuser.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kswdmcap.ax', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\mfc42.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\vsnpstd3.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\qedit.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comdlg32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ddraw.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\dciman32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\d3dim700.dll', no matching symbolic information found.
First-chance exception in opticalFlow.exe: 0xC0000005: Access Violation.

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:

Select allOpen in new window

 

by: itsmeandnobodyelsePosted on 2009-08-13 at 02:22:23ID: 25086518

>>>> First-chance exception in opticalFlow.exe: 0xC0000005: Access Violation
That isn't a codeline but only the runtime exception.

To get a break in debugger you need to start the application - built in debug mode - from the IDE. Then the debugger would break and you could check the call stack.

 

by: gen12324Posted on 2009-08-13 at 03:29:26ID: 25086803

hmm.. I saw the call stack..
This is the line of error..
for(i = 0; i < color_img->height; i+=step)
{
      for(j = 0; j < color_img->width; j+=step)
      {
            points[0][count] = cvPoint2D32f(j, i);
            points[1][count] = cvPoint2D32f(j, i);
            count++; // count the number of points
            
      }
 
 
}

 

by: itsmeandnobodyelsePosted on 2009-08-13 at 03:36:45ID: 25086834

>>>> This is the line of error..

You definitively need to check for count < MAX_COUNT e. g. like

#include <assert.h>
....

 for(i = 0; i < color_img->height; i+=step)
{
      for(j = 0; j < color_img->width; j+=step)
      {
            assert(count < MAX_COUNT);    // would break in debugger in case the condition is false

            points[0][count] = cvPoint2D32f(j, i);
            points[1][count] = cvPoint2D32f(j, i);
            count++; // count the number of points
           
      }
 
}


 

by: gen12324Posted on 2009-08-13 at 03:42:42ID: 25086857

so where can i get the assert.h?

 

by: gen12324Posted on 2009-08-13 at 04:20:45ID: 25087046

I have done the code you given to me.. Got abnormal termination. When i click "retry", it prompt me to find source. "Enter path for CRTOMSG.C"

I do not know where to find it..

 

by: itsmeandnobodyelsePosted on 2009-08-13 at 06:15:32ID: 25087809

>>>> I do not know where to find it..
You must not find the final source. Check only the call stack window and click to first function beginning from above where you have the code for. CRTOMSG.C is a C runtime function probably outputting a message. It is most likely that it got a NULL pointer instead of a valid char pointer to some message text.

 

by: gen12324Posted on 2009-08-13 at 18:25:54ID: 25094621

So after if i'hv click to first function beginning from above, what should i do from therE?

 

by: gen12324Posted on 2009-08-13 at 18:36:19ID: 25094661

itsmeandnobodyelse:

Thanks for your help. Anyway i guess i will stop trying that program. Do you know any source code that have background subtraction with optical flow?

 

by: itsmeandnobodyelsePosted on 2009-08-13 at 23:40:48ID: 25095666

>>>> So after if i'hv click to first function beginning from above, what should i do from therE?
You need to click on any of the functions until it jumps to a known source. Then analyze the local variables and arguments for NULL pointers.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...