LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Basler camera

Solved!
Go to solution

Hi everyone,

I have attached my code here which works fine, vision acqusition and imaqe out works perfect. I am able to record a video by pressing start recording button.

The thing is after running a the vi, it opens a avi and when I press record it writes a video. But if during the running vi, I stop the recording and change the name of path file to create a new video. It is not able to do that. It will overwrite to the first one.

Additionally, I want to get date and time automtically on the name of saved video. Is it possible? 

Thanks in advance

0 Kudos
Message 1 of 7
(291 Views)

Your "AVI path" control and the "Create" node it goes into are both outside of your While loop.  That means they run once at the start and never again.

 

You'll need to change up your code to put them inside the loop, running once each time you start recording.

Message 2 of 7
(269 Views)
Solution
Accepted by topic author Natig

I see that you are using an Express VI, which "hides" many of the important features of LabVIEW vision from you, and leaves you with limited control of the acquisition and processing of the images.  You seem to be using only a few parameters -- among other things, it is not clear to me (because I don't have your camera connected) what the frame rate of the camera is, and how it relates to the 80 fps for the Motion JPEG .avi file.

 

Do you want to turn the Camera on, look at Image Out for a while, then acquire Images for a period of time ("Start Recording" set True), pause the recording ("Start Recording" set False), then resume recording ("Start Recording" set True) and maybe have multiple sequences of recorded frames, with no obvious way to tell when one stops and the next starts)?

 

Think of the sequence of Events that you want to achieve, and design your code to fit that.  If you want "Continuous Video Images" (viewed in Image Out) and multiple AVI videos that are started at "Start Recording" = True and ended at "Start Recording" = False, they need to be inside the While Loop.

 

As you note, a good idea is to include Date and Time in the name of your AVI.  Are you familiar with the Timing Functions?  With them, you can create a Date/Time string (such as "3 Mar 25, 13:24:12" that can go before or after any other name you want to give the series of Videos from this particular run.

 

Bob Schor

Message 3 of 7
(256 Views)

If I do that. take file path and create vi inside loop but outside I get multiple pictures not a video. In this case place close vi outside loop. 

If I place close vi inside loop I also get multiple videos. 

 

And when I place create vi inside case structure then I can not place close vi outside loop or case structure because I need smt to connect to close vi in false case. 

0 Kudos
Message 4 of 7
(182 Views)

This express vi indeed gives me All the features that were originally in Basler camera Software, and it is easy to build, that is why I choose it. But I am not aware which features İ am missing this.

 

Unfortunately Main Problem that I have still insists.

İf I put path and create vi inside loop I get multiple number of pictures instead of a Video. I believe it is because of loop, it creates new file continously.

Should I put path and create vi inside case structure? Where should I please close vi then?

Because for false case I need something to connect to close vi if İ place it outside case. İnside case İ get again multiple pictures.

 

80 fps - with other numbers İ did not get real results. I observed that I take for example for 30 seconds of experiment are indeed producing more than or less than 30 seconds. Maybe this is not best solution for that problem.

 

0 Kudos
Message 5 of 7
(166 Views)

I noticed that you marked my Reply (#3) as the "Solution" to your post, but from your last two posts, it appears that you are still not getting good AVIs.

 

Do you understand how IMAQdx handles cameras, and the concept of Buffers?  Briefly, when you initialize a Camera to do videos, you tell it (among other things) how many "buffers" you want to allocate for frames.  Suppose you are recording at 80 fps, and want 256 x 256 RGB pixels.  This means each image is 256 x 256 x 4 (32 bits = 4 bytes) = 262,144 bytes, so 1 second of video will require about 21 MB (not a big deal).  Why did I specify such a big buffer?  You can probably write to disk faster than 21 MB/s, but when you decide to open a file, write (all of) the data to the file, then close the file, you need to allow a little time to get the process started and stopped, hence you buffer the data to give yourself some time.

 

To do Video writing, you want to use something like a Producer/Consumer pattern driving a State Machine that does the writing.  The State Machine does the following steps:

  • Initialize Video.  Create a buffer to hold a (named) Image, and define the Camera.
  • Open AVI.  Save the LastBufferNumber property as the "Beginning Buffer" in a Shift Register (so you know where to start saving from).  Open a file path for the AVI, call AVI2 Create (I used Motion JPEG (NI Vision), and call the Save Frame State (next one).  Depending on circumstances, you can also save (in another Shift Register) the Last Buffer Number you'll need to save (for example, to save 4 seconds, you'll need to add 320 to the current LastBufferNumber).
  • Save Frame.  If there are more frames to save (i.e. you haven't reached the Last Buffer Number yet, do Save Frame again.  Otherwise, do Close AVI.
  • Close AVI.  This does the obvious.
  • Exit.  This shuts down this Consumer.  You get the Producer to send this message when you are all done writing however many Videos you want (I was writing one video per "interesting behavior", which was being monitored by the Producer, who called the Consumer ("Video") when it wanted another video to be made.

This code is at least 10 years old, and I'm not at liberty to share it.  But the pattern should, I hope, be understandable.  You do need to know a bit about IMAQdx, particularly the concept of Camera Buffers (areas in memory that the Camera uses to save the images it creates, communicating over USB, FireWire (obsolete now, I think) or Ethernet (which our cameras used).

 

Bob Schor

 

Message 6 of 7
(100 Views)

Thank you for your answer. Yes, I still have that problem. 

 

As far as I understand, with your method I will not need Express Vi to get images. 

My question is this: Express VI gives me the opportunity to include every feature that was in Basler software. I assume most of the features are very common, but I have a light that is not exactly related to picture quality; it is like an auxiliary device that was originally in Basler software and included in Express VI as well. 

 

"This code is at least 10 years old, and I'm not at liberty to share it." - Is it also not available in examples folder in labview?

 

I have seen some examples with producer/consumer in LabVIEW. I am going to try to understand them to solve my problem. 

0 Kudos
Message 7 of 7
(37 Views)