Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying IMAQ picture via Media player

Hi,
I am trying to write a program that will open media player on the front panel, via active x controls, and play a looping video of images beignning aquired.  I am able to create the avi file fine and get the first image to be written to the avi file and start playing on the front panel.  The problem occurs when I try and add a new frame to the avi file.  In my program, when the new picture is ready to be added to the avi file, I stop media player, close media player reference, open the avi file, and then write the new frame to the file.  I am unable to write the new frame because LV says the avi file was open for reading only, not writting.  If I try and use the "Create Avi" vi, LV complains that the file is "not accessable."  My guess is that media player is still using the file.  I have attached a pesudo code of what my program does.  This is how I think the flow of the program should go:
 

1. Open the file to play until the new picture is ready

2. New picture is ready

3. Stop media player

4. Close media player reference

5. Write frame to avi file

Then repeat.

Is this possible?

Adam

0 Kudos
Message 1 of 5
(3,296 Views)

Sorry, I posted the wrong code.  That was code I used to to use classic media player because we are using LV 7.1.  Here is the pusedo code I was talking about.

Adam

0 Kudos
Message 2 of 5
(3,287 Views)
Hi Adam,

I see that this issue is also being discussed in a different thread.  I would agree with Jasper that it appears you are writing and viewing processes in parallel.  I would suggest simplifying your code (i.e. replacing the stacked sequences with linear code using error handling to control the data flow, cleaning up wires, etc.) It is often easier to debug code if the data flow is more apparent.  You would then be better equipped to use highlight execution and break points to check if you have any race conditions. 

Often, ActiveX functions may take some time to complete; therefore after you call the close command I would add a delay to give enough time to completely close the reference.  Also I would suggest taking a look at the AVI examples in LabVIEW – in particular the Grab and Save to AVI.vi.  If you are able to get this program to work correctly, you can then begin incorporating the appropriate ActiveX functions to open Windows Media Player.  

I hope this helps.  Please let me know if you would like further clarification or assistance regarding this issue.


Regards,

Vu D
0 Kudos
Message 3 of 5
(3,271 Views)
I looked at the exmaples provided by labview.  Those helped me perform some more error checking, but I still am not able to update teh avi file with the new frame.  I tried writing the program bare, with a simple update file, same picture to avi handoff.  I don't think it is possible to create the avi ref, close the avi ref, and then reopen the avi ref for writing.  Even adding a 10000 mil wait after closing the media ref, the program would still now let me recreate teh avi.  Accodring to the error checking I put in, the ref to media player is closing and the program waits until IMAQ is done writing the avi frame.  I read some after market vi's that claim they can open the avi for wiriting.  Here is a picture from their site:
Image125.gif (2892 octets)
They are using the avi library for labview, here is their web address:
 
Is there a way to edit the IMAQ vision "Open avi file" to include an option which allows the file to be opened for wrtiting, and then append the new picture to the existing avi?
 
Adam
0 Kudos
Message 4 of 5
(3,235 Views)
Hi Adam,

After further investigation, the current AVI functions open a session to either read or write, but cannot do both; therefore, if you would like to append a video, you will first need to open and read in the video frame by frame, close the session, and then create a new AVI reference to write those frames again with the new images that you would like to append.   I am sorry for misinterpreting your code earlier.  Your code appears to have many structures that would be made unnecessary by using data flow to control the sequence of operations.  The simplest and most effective way of doing this can be to pass the error out from one VI to the next.  In addition to using the error cluster to control the order of execution, connecting the errors in this way will allow you to handle any errors that occur.  Code that uses the data flow paradigm is often much easier to follow as you can see the data flow with highlight execution.

Regards,

Vu

0 Kudos
Message 5 of 5
(3,208 Views)