Jump to content
花落阳关

simultaneous acquire and save video files

Recommended Posts

Hello, everyone!

I want to  synchronous acquire and save video files via a GIGE camera while not influence the frame rate. I achieve the program as below, but the frame rate is highly unstable. I hope you can offer some ideas, thanks!

 

 

acquire and save video.png

Share this post


Link to post
Share on other sites

A producer-consumer architecture, with a queue of images to be saved by the consumer loop, is the first thing you should really try. Alternatively and asynchronously grabbing one image from each loop for either viewing or saving, like you do, wont bring you far. Also, rendering the preview image might be resource intensive and compete with saving, you may want to display only one every N images. Finally, AVI could involve compression codecs, which can also be computationally demanding; to maintain a given frame rate you might have to stream uncompressed images, or to choose a less demanding codec, to reduce the image size.

Share this post


Link to post
Share on other sites
16 hours ago, ensegre said:

A producer-consumer architecture, with a queue of images to be saved by the consumer loop, is the first thing you should really try. Alternatively and asynchronously grabbing one image from each loop for either viewing or saving, like you do, wont bring you far. Also, rendering the preview image might be resource intensive and compete with saving, you may want to display only one every N images. Finally, AVI could involve compression codecs, which can also be computationally demanding; to maintain a given frame rate you might have to stream uncompressed images, or to choose a less demanding codec, to reduce the image size.

Thanks, I can achieve the result via use the producer-consumer architecture with a better frame rate. But now there is a question, everytime run the program it will automatically generate a .avi file and it always be a empty file(0 byte).Now I want to add a case structure, when the case button was pressed it save to a avi file.If it was not pressed,the empty file won't be generate. You can directly modify in the vi file,thanks!save to avi.png

Grab and save avi.vi

Share this post


Link to post
Share on other sites

I don't see a producer-consumer in your VI. That is e.g. two loops, enqueueing and dequeueing image references, or something equivalent. You create an AVI file at start because your program does so, you might want to do it rather only after the button is pressed. And I would handle that with an event structure and a shift register propagating the file reference from one iteration to the next. Maybe you'd want to check some LV learning resource first?

Share this post


Link to post
Share on other sites
On 2017/12/6 at 3:56 PM, ensegre said:

I don't see a producer-consumer in your VI. That is e.g. two loops, enqueueing and dequeueing image references, or something equivalent. You create an AVI file at start because your program does so, you might want to do it rather only after the button is pressed. And I would handle that with an event structure and a shift register propagating the file reference from one iteration to the next. Maybe you'd want to check some LV learning resource first?

Thanks, I had achieved the result using the  producer-consumer,you can see it in the vi file. But I wanna to pressed the Boolean 2-5 to create avi files, otherwise it while generate many empty file, but the present program can just be pressed once, because the corresponding while structure will be end up. When I want to modify file name to generate a new avi file, it cannot be run(because it just could run once).So now I have two questions:

1. How to modify the program to achieve  continuous operation to generate a new avi file?

2. The pixels are 1080*720, 30 fps, 20s could generate 2G data, how can I  achieve compression and transmission of videos,then decoding and saving the avi file?

save avi.vi

Share this post


Link to post
Share on other sites
On 12/8/2017 at 11:44 AM, 花落阳关 said:

1. How to modify the program to achieve  continuous operation to generate a new avi file?

Basic LV programming question. One way is with event frames. You should only open the AVI file when the boolean changes from false to true and close it when it reverts to false.

Share this post


Link to post
Share on other sites
On 2017/12/10 at 1:13 AM, ensegre said:

Basic LV programming question. One way is with event frames. You should only open the AVI file when the boolean changes from false to true and close it when it reverts to false.

Now there is still some question with the program, it can not be wrote to avi, just the last frame,I don't know why. Help me modify it to run, thanks!

Grab and SAVE AVI.vi

Share this post


Link to post
Share on other sites

Dataflow.The small loop runs only after the big acquisition loop ends. You probably have no choice but to communicate the avi file reference and the writing status from one to the other via local variables. Or a channel wire perhaps.

Share this post


Link to post
Share on other sites
1 hour ago, ensegre said:

Dataflow.The small loop runs only after the big acquisition loop ends. You probably have no choice but to communicate the avi file reference and the writing status from one to the other via local variables. Or a channel wire perhaps.

I just want to add three button(grab,save and stop).Press grab to start to display on the front panel, press save button to generate a avi file(not generate one when the button is not pressed),press again to end the save mode. Press stop to end the whole program, could you please help me modify it, I had tried many times. 

Share this post


Link to post
Share on other sites
On 12/19/2017 at 5:23 AM, 花落阳关 said:

I just want to add three button(grab,save and stop).Press grab to start to display on the front panel, press save button to generate a avi file(not generate one when the button is not pressed),press again to end the save mode. Press stop to end the whole program, could you please help me modify it, I had tried many times. 

Hi, I know this was posted a long time ago, but did you ever get this working? I am trying to write a .vi that does the exact thing you are describing. I'm having the same issue of only saving the last frame. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Similar Content

    • By hutha
      New Toolkit : OpenCV wrapper for Raspberry Pi (LinuxRT) for LabVIEW
      Great ! learning platform student and maker for learning machine vision application with LabVIEW.
      It's working with LabVIEW Home 2014 edition and  required LINX 3.0 toolkit.
      You can run NI-VISION toolkit with Raspberry Pi board too.
      1.QwaveCameraCV is a LabVIEW Camera Driver library for Raspberry Pi 3B/3B+ (LinuxRT)
      https://github.com/QWaveSystems/QwaveCameraCV


      2.QwaveOpenCV is OpenCV wrapper functions for LabVIEW for Raspberry Pi 3B/3B+ (LinuxRT)
      https://github.com/QWaveSystems/QwaveOpenCV


      3.QwaveOpenCV Examples using OpenCV (C/C++) and NI-VISION for Raspberry Pi 3B/3B+ (LinuxRT)
      https://github.com/QWaveSystems/QwaveOpenCV-Examples


       
    • By Shaun07
      Hello,
       
      I need one help regarding changing the image image type
      How can I convert grey scale image to false color image?
      Here, I have attached two images. 1. greyscale image 2. is just an example that I want to convert. (False Color). 
      Any help would be appreciate.
       
      Thanks,
      Parth Panchal 


    • By Shaun07
      Hello All,
       
      I am new to the camera labview programming. 
       
      For my research work, I am using camera to grab the live image. I am stuck with one problem. 
      how to treat the background?
      I tried to subtract the constant value from the entire image, but with that i am loosing few of my data.
      I know one solution, but I don't know how to implement this solution. 
      Problem: how to take the values from the 4 corner of the image and subtract those value from entire image?
       
      If anybody previously develop similar stuff then please help me out for this. 
       
      Any help would be appreciate.
       
      Thanks,
      Shaun

      removebackground.vi
    • By Shaun07
      Hello All,
      Did any one previously used Imaging source camera (DMK series)? If yes, then please give me a reply. I need one help regarding Camera Attributes.
      Thanks,
    • By ASalcedo
      I would like to know if there is a parameter in line scan camera which allow me to control time trigger along NI MAX or labview with imaqdx.
      I mean, I would like to triggering camera during 100ms which specific shutter and specific line/sec.
      And if I change shutter or line/sec the time trigger keep being the same (100ms)
      I don't know if this is possible with some parameter of line scan camera.
      Thanks a lot.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.