Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Using CVI to Read an AVI

Solved!
Go to solution

Hi,

 

I am trying to read an AVI in my CVI code, but it isn't working.  I am able to read the same AVI fine in a VI, just not on the C side of things.  Here is the code I am using:

 

	AVISession session = 0;
	session = imaqOpenAVI("C://MKX.avi");
	int error = imaqGetLastError();

	AVIInfo *info = NULL;
	imaqGetAVIInfo(session, info);

	printf("There are %d frames at %dx%d\n", info->numFrames, info->height, info->width);

 

The call to imaqGetAVIInfo returns null.  I made sure the path to the AVI was correct. 

 

Any suggestions are much appreciated.

 

Shawn

 

0 Kudos
Message 1 of 5
(2,917 Views)

Have you tried "C:\\MKX.avi" for the path? (use backslashes instead).

 

-Christophe

0 Kudos
Message 2 of 5
(2,913 Views)

Whoops, that was an error in my code posting.  That was left over from trying "/" instead of "\\". 

 

imaqOpenAVI returns 1, which I think means it opened it okay.  I also did a imaqGetLastError after the imaqOpenAVI and it returns 0.  I also added an error check after imaqGetAVIInfo and it comes back with: -1074395269 Null pointer.

 

Am I just missing something obvious with my code?

 

Thank you for the reply.

 

 

0 Kudos
Message 3 of 5
(2,842 Views)
Solution
Accepted by topic author shawnhunt

@shawnhunt wrote:

Whoops, that was an error in my code posting.  That was left over from trying "/" instead of "\\". 

 

imaqOpenAVI returns 1, which I think means it opened it okay.  I also did a imaqGetLastError after the imaqOpenAVI and it returns 0.  I also added an error check after imaqGetAVIInfo and it comes back with: -1074395269 Null pointer.

 

Am I just missing something obvious with my code?

 

Thank you for the reply.

 

 


I haven't looked up the documentation for that function, but it looks like from the way you called the function (and also the error code) that you are passing it a NULL pointer. The function would have no way to return the info you asked for with the way you are calling it. I imagine it expected you to allocate the structure and pass it by reference.

 

Your code should probably be modified like this:

AVIInfo info;
imaqGetAVIInfo(session, &info);

Hope this helps,

Eric

Message 4 of 5
(2,837 Views)

Ah, yes, totally my fault.  I was having a total brain freeze on that one.  Thank you!

0 Kudos
Message 5 of 5
(2,832 Views)