LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write 16 bit images into AVI file

David,

Thanks for the code, I have looked through it, and have successfully ran it without any problems without being able to replicate the streaking. I'm able to save multiple AVI files, and when I view them in Windows Media Player, everything looks great. Does the streaking occur for you when you view the movie files in your program as well as an external AVI player?
0 Kudos
Message 21 of 33
(2,271 Views)

Michael,

I'm glad that my code works well : I can blame something or someone else Smiley Very Happy.

Actually, I can't read the AVI in windows media player : I only get a pink distorted picture (see snapshot "ImaqAVIcolorImage" in one of my previous replies).

I suspect one of the DLL loaded by the application to be in fault, probably caused by software installed on both of my computers.


All those DLLs are loaded on the AVI creation :


'U-GLARES_CO2.exe': Loaded 'C:\WINDOWS\system32\clbcatq.dll', No symbols loaded.

'U-GLARES_CO2.exe': Loaded 'C:\WINDOWS\system32\comres.dll', No symbols loaded.

'U-GLARES_CO2.exe': Loaded 'C:\WINDOWS\system32\qcap.dll', No symbols loaded.

'U-GLARES_CO2.exe': Loaded 'C:\WINDOWS\system32\msvfw32.dll', No symbols loaded.

'U-GLARES_CO2.exe': Loaded 'C:\WINDOWS\system32\quartz.dll', No symbols loaded.

And those two ones when saving the first AVI frame :


'U-GLARES_CO2.exe': Loaded 'C:\WINDOWS\system32\devenum.dll', No symbols loaded.

'U-GLARES_CO2.exe': Loaded 'C:\WINDOWS\system32\msdmo.dll', No symbols loaded.

 

When I first use VISION and AVI reading on my computer, I get a conflict with a file from NERO (media player and/or disc burner). So, I now think that any software can interfere with my application !


I’m quite busy for the next days, but if I have some time, I will try with another computer (again !) with less stuff on it.


David

0 Kudos
Message 22 of 33
(2,258 Views)
Sounds great David! Let me know how it goes.
0 Kudos
Message 23 of 33
(2,246 Views)
Hi Michael,

I tried my code on a third computer and I still get the black stripes on the second AVI.

When you have run my code, did you use a PCI-1410 card ?

Thanks

David
0 Kudos
Message 24 of 33
(2,233 Views)
David,

Yes, I was running with a 1410. Here's an idea we might try though. Look at the array data (in numeric form) for the first image that you capture and save to avi. Next, look at the array data (again in numeric form) for the first frame that you read from the avi you created after having already saved it. Compare the two values to see if the data is the same. If they are different, than it may indicate that something in the conversion process went wrong.
0 Kudos
Message 25 of 33
(2,216 Views)
Hi Michael,

As you suggested, I read the first array in numerical format before saving and compared it with the first avi frame when reading and the values are identical :
92 02 29 02 21 02 92 02 51 02 fd 01 6a 02 83 02 32 02 4c 02 8f 02 4e 02 26 02 70 02 72 02 32 02 4f 02 94 02 57 02 3a ...
92 02 29 02 21 02 92 02 51 02 fd 01 6a 02 83 02 32 02 4c 02 8f 02 4e 02 26 02 70 02 72 02 32 02 4f 02 94 02 57 02 3a ...
By the way, I did the same thing with the second grabbed AVI. The values were almost the same, except that every fourth byte is replace by "FF" :
38 02 76 02 86 02 61 02 5c 02 7b 02 6a 02 53 02 86 02 87 02 67 02 6b 02 94 02 8e 02 68 ...
38 02 76 ff 86 02 61 ff 5c 02 7b ff 6a 02 53 ff 86 02 87 ff 67 02 6b ff 94 02 8e ff 68 ...
All with the same source code !

Recently, I did many acquisition with the 1410 (saving in 8 bits AVI) and a 1411 color card (still saving in AVI, but RGB) and didn't get any problem.

I will still get an eye on this issue, but priorities have changed here and I will not have many times to continue the investigation. But after so much tries to fix it, I'm very curious to find out what is going wrong.

David


0 Kudos
Message 26 of 33
(2,208 Views)
David,

At least we know a little bit more about where those vertical streaks are coming from now. What's most surprising to me is that each pixel in your array is not of the form "FF 00 XX XX" where FF is the alpha layer, the R value is 00 (because you are casting a 16 bit image into a 24 bit RGB type, and the XX XX represents the hex value of your original pixel data. All of this leads me to believe something is going on with the casting process. Can you verify whether or not the data changes before and after you convert the image to an array and at the same time cast the array into 32 bits?
0 Kudos
Message 27 of 33
(2,195 Views)

Michael,


I’m not sure to understand how to “verify whether or not the data changes before and after you convert the image to an array and at the same time cast the array into 32 bits?”. To do so, do I need to have access to the content of the Image struct (at least, in the memory window) to see the value of each pixel ? I must miss something because I don’t think that the construction of the image struct is documented in NI manuals.



Also, I sometimes get this error message :


A first chance exception of type 'System.AccessViolationException' occurred in U-GLARES_CO2.exe


Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

 

At this line of code :

errChkVISION(imaqArrayToImage(ImaqAVIColorImage,AVIlongArray,numCols, numRows));

It may be a big clue that something is going on with the casting process. I don’t know why I didn’t trig on this error before, maybe I was too much focusing on the streaks to make a link with the other error.

 

Thanks again for your help.

0 Kudos
Message 28 of 33
(2,180 Views)
David,

I believe the reason you are getting those error messages is because of this line:
AVIlongArray = (unsigned long int *)imaqImageToArray(ImaqLiveFeedImage, IMAQ_NO_RECT , &numCols , &numRows );

When you cast the pointer, you are only changing the size of the data type that the program is expecting, you are not actually expanding the data from 16 bits to 32 bits. (Which i believe is why we are not seeing data in FF 00 XX XX format) I believe that you get this error sometimes because you are trying to access the same number of rows and columns, even though it has been effectively halved, because each 32 bit pixel is actually comprised of 2 16 bit pixels. It is possible that the streaks you are seeing are remnants of the first AVI. Please try manipulating the array data itself so that each pixel is actually converted into 4 bytes, instead of just casting the pointer type, and seeing if you get the same problems. Alternatively, try halving the number of columns and rows when saving the AVI and seeing how this affects your image.
0 Kudos
Message 29 of 33
(2,167 Views)
Hi Michael !

Good guess ! There is no more streaks on any avi.

Now, I just have to find a way to make it working faster (using for loops to do the conversion is slowing down my application). But at least, I have a good starting point !

Thank you for your long-term support on this topic.

Regards,

David
0 Kudos
Message 30 of 33
(2,159 Views)