From: Chris on
Hellooooooooo :) :)

I want to implement car detection with optical flow in MATLAB, as shown in :

http://www.mathworks.com/products/viprocessing/demos.html?file=/products/demos/shipping/vipblks/videotrafficof.html

but initially, I have to "Create a System object to read video from a binary file" , using the code :

hbfr = video.BinaryFileReader( ...
'Filename', 'viptraffic.bin');


, but I have an .avi file that I want to use for car detection... Should I convert .avi to .binary file? I do not understand how to do it...I also get the error ??? Undefined variable "video" or class "video.BinaryFileReader"... when I use the command above...

I am sorry but I cannot understand...

Thank you so much for your help.
From: Don Orofino on
Hi Chris,

The BinaryFileReader object may be used to read raw data streams from a video file. It will not recognize or react to file formats, headers or compression beyond some basic data layout options, so it's not the best approach for .avi files.

Instead, use the video.MultimediaFileReader object. This will recognize AVI files and handle data compression based on your platform/OS.

System objects are available beginning with R2010a; the video objects ship with Video and Image Processing Blockset. If you use an earlier version of MATLAB, you will not be able to work with System objects. This could be a source of the error message you cite.

--Don

"Chris " <chris_sar(a)hotmail.com> wrote in message <hrgtck$1g3$1(a)fred.mathworks.com>...
> Hellooooooooo :) :)
>
> I want to implement car detection with optical flow in MATLAB, as shown in :
>
> http://www.mathworks.com/products/viprocessing/demos.html?file=/products/demos/shipping/vipblks/videotrafficof.html
>
> but initially, I have to "Create a System object to read video from a binary file" , using the code :
>
> hbfr = video.BinaryFileReader( ...
> 'Filename', 'viptraffic.bin');
>
>
> , but I have an .avi file that I want to use for car detection... Should I convert .avi to .binary file? I do not understand how to do it...I also get the error ??? Undefined variable "video" or class "video.BinaryFileReader"... when I use the command above...
>
> I am sorry but I cannot understand...
>
> Thank you so much for your help.
From: Chris on
Thank you so much for your help Don!!! :)

Well it seems that it works with Matlab 2010a, but I cannot understand where the 'viptraffic.bin' file is....

Unfortunately, I cannot use my own .avi file...

And I have a really big problem...

Thank you so muuuch :) :)
From: Chris on
I found the file "viptraffic.bin" (--> binary) and "viptraffic.avi" in

C:\Program Files\MATLAB\R2010a\toolbox\vipblks\vipdemos

but I want to convert my own .avi file to .bin in order to use it...

Thank you so much!! :)
From: Chris on
Well, I finally managed to read my own .avi file with MultimediaFileReader by uninstalling the k-lite codec pack!!

But now, at the end of the whole algorithm described here :

http://www.mathworks.com/products/viprocessing/demos.html?file=/products/demos/shipping/vipblks/videotrafficof.html#1

When I enter the code :

% Calculate and draw the motion vectors.
tmp = of(RV,CV) .* MotionVecGain;
lines = [X(:)';Y(:)';X(:)' + imag(tmp(:))';Y(:)' + real(tmp(:))'];
mv_video = step(hshapeins2, image, lines);

step(hVideo1, image); % Display Original Video
step(hVideo2, mv_video); % Display video with motion vectors
step(hVideo3, th_image); % Display Thresholded Video
step(hVideo4, image_out); % Display video with bounding boxes

I get the error message :

??? Error using ==> step
Reported by video.MultimediaFileReader: Too many output arguments; must be between 1 and 2
(3 requested).

I do not know what this means...

Thank you so much...