LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying IMAQ picture via Media player

Hi,
I have been trying for days now to display an avi file containing pictures aquired via IMAQ vision.  I can get the pictures to save to the avi, but can't get LV to play them on the front panel using media player.  Here is what I have:
I start the program and wait for pictures to be saved to a file.  After they are saved, the vision software takes the pictures and writes it to an avi file determined by the user.  That part works fine.  What I want to do next is have a Media Player control on the Lv front panel which plays these avi's in a "looping" video.  So here is what I have done so far:
I created an active x control for media center (classic because I am using LV 7.1) on the front panel.  I then try and read the avi file created by the IMAQ. 
I keep getting an error about the "avi file can not be accesed."  So I changed the code to close the avi file and then reopen it, but that still does not work.
 
Simplied psuedo code:
Users inputs path to save avi file.
Program creates avi file
Program enters while loop and media player opens and plays avi
Program then enters a sequence where:
1.  Picture is aqcuired
2.  Media player is stop and reference is closed
3.  Avi file is "recreated"
4.  Picture is written to avi file
5.  Avi file is closed
Program waits until next picture is aquired
 
I am going crazy trying to figure this out.
 
Adam
0 Kudos
Message 1 of 8
(4,569 Views)

Hello Adam,

 

Are you able to play the AVI file you generated in a stand-alone session of Windows Media Player (not ActiveX)?  In other words, is a valid Windows Media Player compatible AVI file generated?

 

Regards,

Jasper S

0 Kudos
Message 2 of 8
(4,545 Views)
Yes I am able play the generated avi in media player, after I stop the program. I still can't figure out how to play the avi on the front panel with the updated image after the sequence exits.

Adam
0 Kudos
Message 3 of 8
(4,543 Views)

Adam,

Is the error you are seeing a Windows error or a LabVIEW error?  And is there an error code associated with it?

Can you play ANY AVI successfully in the ActiveX Windows Media Player control?  Can you play the AVIs you create in a separate VI with an ActiveX control?

It may be helpful in this situation for you to post your code to the forum, so we can take a look at how your code is operating.

 

Regards,

Jasper S

0 Kudos
Message 4 of 8
(4,519 Views)

The error I see is generated from LabView.  I don't know off hand what the error code number is, but it complains that the Avi file can not be accessed, file accessed denied.  I can stop the program and open the avi file in Media Player and play it.  I can also play the created avi file from another vi that just opens the avi file and plays it.  Here is the pseudocode I am using to run the program.  I chopped out the image recongintion and anyalsis because it has no bearing on how the avi file is handled.  The way I have the code structured now, I believe it will not append the avi file, but overwrite it with the newest image.  What I am trying to do is take the newest image and added it the avi file, while LV is playing the avi file.  I thought by stopping and closing media player, then writing the new image to the avi file, and then reopen Media player to play the new avi file would allow the file to "not beigning used."

 

Adam

0 Kudos
Message 5 of 8
(4,511 Views)

Adam,

While you can continually play and write to an AVI file in LabVIEW, you will never be able to continually write to and play an AVI file in Media Player, even through ActiveX.  LabVIEW can internally share the AVI file resources, but externally there is no way to manage the sharing of the AVI file between Windows applications (LabVIEW and Media Player).  From looking at your code it appears you have the writing and viewing processes happening in parallel.  And as you said, Media Player will have to release its hold of the file before LabVIEW can access it.  You will need to make sure that you know the order in which these independent portions of code (acquisition and playback) will be happening.  Knowing the order of operation will allow you to ensure that you have closed all your references before you pass the file on to be played or appended.

Regards,

Jasper S

0 Kudos
Message 6 of 8
(4,488 Views)

I thought the flow of the opening and closing the media player would go like:

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

2. Stop media player

3. Close media player reference

4. Write frame to avi file

Then repeat.

The problem is, if I use the "Open avi" vi, it opens the avi file fine, but will not write a new frame to it.  LabView gives the error "Avi file is open, but only for read."  If I try the "Create avi" vi, that will rewrite the the avi and not append the avi file.  Is it possible to do this.

Adam

0 Kudos
Message 7 of 8
(4,483 Views)

Adam,

We have been discussing this issue in the CVI forum, and I believe it would be very beneficial for you to start a thread in the Machine Vision forum, linked here, so that other readers of the forums can contribute to our discussion.  Make a new thread, and we will link it back to this one.

Regards,

Jasper S

0 Kudos
Message 8 of 8
(4,450 Views)