Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Combining 2 camera outputs to write just 1 .avi file

Hello,
 
I've looked through the responses to some similar questions, and have tried to cobble together a solution (see attached below).  All i want to do is save the output from two 1394 cameras (both 640x480 8-bit output) and then save them as a single .avi file so that they play side by side.
 
For some reason my solution seems to pick just one of the cameras and play the output from that, making me think that the offset isn't working?
 
Could anybody please have a quick look and tell me what's wrong?  And also, if anyone could recommend a good beginners tutorial to the Vision functions in LV that would be great.
 
Cheers
 
Bruce
0 Kudos
Message 1 of 10
(4,856 Views)

Hey Bruce,

What version of LV do you have?

The vi you have created isn't going to give you the desired results.  You are currently only aquiring images from a single camera and you need to aquire from both and THEN combine the images (you are only combining the first images together (both unpopulated) which won't do as you need)

Here is a piece of code that I tried a few months ago to do just as you wish.

Try this out.. see what you get.

(p.s you might want to look up how to set up 2 cameras in MAX.. you need to make sure you have enough firewire bandwidth to aquire on both cameras at once)

AdamB

Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 2 of 10
(4,852 Views)
Oh yeah and .....(I'm having one of those days)
 
You might want to change the data types I am using (I was using an RGB camera AND a greyscale (8-bit))
 
AdamB
 
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 3 of 10
(4,848 Views)

Hi Bruce,

Did you have any luck with that code?

Thanx

AdamB

Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 4 of 10
(4,835 Views)

Hi Adam,

Sorry i didn't get back to you yesterday i was in meetings all afternoon.  I slightly modified the vi that you sent, to work with 2 x 8-bit grayscale cameras and it worked pretty well, although the results did seem quite a lot slower than when i was running 2 cameras simultaneously without combining them?  I also noticed that on the front panel, underneath the screens it mentioned something about "1/2 8-bit" or something like that.  I guessing that the "1/2" is something to do with the reduced speed?

There were a few things going on in your code that i'm not really sure about, but let me have a more thorough investigation of it today.

Thanks very much for your help though, i would be in trouble without it!  I'll let you know how i get on later today.

Bruce 

0 Kudos
Message 5 of 10
(4,827 Views)

Hi AdamB,

I've had a shot at building a new code based heavily on the code that you sent me, as attached, but it doesn't run and comes up with 'Error 1074364379' camera already in use. 

On the front panel, the one camera which is displayed has '1/1 8-bit image' appearing underneath it......suggesting that it's not realised that there are actually 2 cameras being used '1/2 8-bit image' as yours did.

Don't know if this is important but, in MAX the cameras both have the following settings:

Video Moe: 640x480 Y (mono 😎 15.00fps

Timeout:  5000ms

Speed:  200Mb

You'll also notice that i didn't use a timed loop as you did, mainly because i wouldn't really know what i was doing with one!!  Could this be the source of my problem?

Thanks again.

Bruce 

Message 6 of 10
(4,821 Views)
Hi Bruce,
 
Well there could be two reasons for the problem and neither are the timed loop (you're safe there) Smiley Wink
 
Firstly
You need to wire the name of the camera's into the initialise vi's that you are using.  (if you don't the default value will be used for BOTH vi's.. and this is Cam0)
If both initialise vi's are trying to access cam0 you will get this error.  Name them as they are named in MAX (I would suspect they are cam0 and cam1
 
And
 
Secondly
If you have MAX open at the same time as you run your program this error will show up (MAX get's a handel to the camera's and won't let LabVIEW use them)
 
One other thing.. it might be an idea to wire the output from the bottom aquire to the input to the "Image size.vi".  As I suspect without this your next error will be because the image size returns "Not an image" because on the first run you will be trying to get the size of an image that hasn't as yet been aquired.
 
Hope this helps
 
Let me know how you get on
 
AdamB

Message Edited by AdamB on 11-03-2006 09:56 AM

Applications Engineering Team Leader | National Instruments | UK & Ireland
Download All
Message 7 of 10
(4,820 Views)

Hi Adam,

Thought it might be some schoolboy error like that!  I made the changes and it works perfectly. 

Thanks again, that was a huge help.

Have a good weekend.

Bruce

0 Kudos
Message 8 of 10
(4,811 Views)

Hi AdamB,

I wondered if you might be able to advise me on my options for compressing my .avi files to a more managable size.  The application i want to use this code for will invovle recording an activity that will take up to 60 minutes.  I will then likely have to spend many hours trawling through these, stopping, rewinding, fast-forwarding, etc.

I have experimented with a couple of the compression filters:  'MJPEG Compressor' doesn't seem to reduce the file size by much, although 'Indeo video 5.10 Compressor' does seem to be very effective.  The problem with that is when I play the file in media player, as well as reducing the file size it has also compressed 1 minutes worth of footage in to about 15 secs.  Does this mean i need to do something to decompress the file before i view it?

I have my cameras set to 15 fps, and in 'IMAQ AVI Create' i have made sure that it creates at 15 fps, reduced the 'max data' down to 5000 and the 'quality' always seems to default to -1, even when i'm not using a filter.  I can reduce the cameras to 7.5 fps in MAX, but for some reason the input to the 'IMAQ AVI Create' doesn't like me using a non-integer.

Could you please advise me:  What are my options for reducing the file size, in a way that will not cause too much hassle when i want to sit and analyse the recordings?

Best regards,

Bruce

0 Kudos
Message 9 of 10
(4,769 Views)

Now answered on this forum:

http://forums.ni.com/ni/board/message?board.id=200&message.id=11712

______________________________________________________________________________________

Hi Bruce,
 
Saw your other post and then this one.  Below is a list of the filter names I have (I found this by using the IMAQ AVI Get Filter Names.vi)  Different programs do give exposure to different codecs.
 
DV Video Encoder
Indeo® video 5.10 Compression Filter
MJPEG Compressor
Cinepak Codec by Radius
Intel Indeo(R) Video R3.2
Intel Indeo® Video 4.5
Indeo® video 5.10
Intel IYUV codec
Microsoft RLE
Microsoft Video 1
I also found that Indeo seemed the best one.  Now with your program how often do you actually take an image of the objects?  (try placing a milisecond counter and see how many miliseconds there are between each image on average)  You may find that the images are being sampled at a higher rate then the one you have set in MAX.
 
Your program will tell the cameras to sample at the quickest rate they can in their current setting.  You may need to add a delay to the while loop (or make it a timed while loop) and set the delay to 1/15th of a second (66ms) then you should get the results are looking for?
(assuming you set the AVI to record at 15 fps)
 
Give that a go?
 
AdamB
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 10 of 10
(4,762 Views)