花落阳关 Posted December 5, 2017 Report Posted December 5, 2017 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! Quote
ensegre Posted December 5, 2017 Report Posted December 5, 2017 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. Quote
花落阳关 Posted December 6, 2017 Author Report Posted December 6, 2017 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! Grab and save avi.vi Quote
ensegre Posted December 6, 2017 Report Posted December 6, 2017 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? Quote
花落阳关 Posted December 8, 2017 Author Report Posted December 8, 2017 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 Quote
ensegre Posted December 9, 2017 Report Posted December 9, 2017 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. Quote
花落阳关 Posted December 19, 2017 Author Report Posted December 19, 2017 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 Quote
ensegre Posted December 19, 2017 Report Posted December 19, 2017 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. Quote
花落阳关 Posted December 19, 2017 Author Report Posted December 19, 2017 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. Quote
mad2johnson Posted July 21, 2020 Report Posted July 21, 2020 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. Quote
Natiq Posted March 19, 2025 Report Posted March 19, 2025 On 12/19/2017 at 12:23 PM, 花落阳关 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 dont know if we must use producer\consumer to be able to record multiple videos. Is it necessary or we can just put event frame inside same loop. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.