videoinput versus videodevice for realtime processing

11 views (last 30 days)
Quentin
Quentin on 4 Feb 2014
Hello all,
I have written a simple machine vision script in my lab to detect objects moving around in a pre-recorded video. It works really well and I am happy with its performance. I would now like to move it into real time tracking and I am looking for a little guidance on the best way to handle this. We are using a new i7 PC running Matlab R2013b with a solid state hard drive. We have a pointgrey gige blackfly camera. I'm hoping this should be a fast enough set up. Our algorithm basically just takes a lot of frames initially to get a "mean frame". This is then subtracted from each frame of the video so that only the objects moving are now visible. So basically, we would take a single frame, process it, then take another single frame, and repeat.
There are two main points which I'm not sure of. The first is whether I should use videoinput and trigger each frame individually between processing of if we should use videodevice, since it is designed for single frames. The issues with videodevice is that I could not figure out how to get a timestamp for each frame (we would like millisecond precision ideally). Next is the issue of collecting many frames. Is there an easy way to have matlab stream this information to the hard drive so that we could collect tens of minutes of processed video data?
Any tips would be greatly appreciated. Ciao, Quentin
  2 Comments
William Chamberlain
William Chamberlain on 19 Aug 2016
Glad to hear that you resolved your issues, because I have almost exactly the same requirements!
Could you post code snippets for your configuration, or a list of properties & values to set, or links to any code that you have released?
Thanks, Will

Sign in to comment.

Answers (3)

Quentin
Quentin on 10 Feb 2014
Edited: Walter Roberson on 9 Sep 2015
Thank you for the help on this Sean. I've rewritten the code so that the camera can simply be triggered by an external device. The idea would be to have this trigger the device at a steady 30 fps and then matlab could perform the computations in between. The issue that I'm having now is that I can't get Matlab to configure the camera for the triggering. I'm using,
imaqreset;
vid = imaq.VideoDevice('gige', 1);
set(vid, 'ROI', [1 1 640 240]); %[x y width height] use 640 240
set(vid, 'HardwareTriggering', 'On');
set(vid.DeviceProperties, 'FrameStartTriggerActivation', 'RisingEdge');
All of this works loads and returns no errors. However, when I now run
start(vid);
I get the error
Error using imaq.VideoDevice/start (line 478)
Invalid use of START method on VideoDevice System object. Use the
STEP method to acquire a frame.
If I use frame = step(vid);
I get the error,
Warning: The videoinput object is configured for hardware
trigger, however, no TriggerMode properties have been set to
'On'. The most likely result of this will be immediate
acquisition.
What I am trying to do is just have it collect a single frame per trigger to continue my while loop. I cannot figure out how to set a specific TriggerMode. I know the camera is capable of "Mode 0" but if I look get(vid), I just get
Device: 'Blackfly BFLY-PGE-13E4M (gige-1)'
VideoFormat: 'Mono8'
DeviceFile: ''
ROI: [1 1 640 240]
HardwareTriggering: 'on'
TriggerConfiguration: 'DeviceSpecific/DeviceSpecific'
ReturnedColorSpace: 'grayscale'
BayerSensorAlignment: 'grbg'
ReturnedDataType: 'single'
DeviceProperties: [1x1 imaq.internal.DeviceProperties]
So I'm not sure how to work with the DeviceSpefic setting. The camera is a new Pointgrey blackfly.
Any help is greatly appreciated.
Quentin
  1 Comment
Andrew Davies
Andrew Davies on 9 Sep 2015
Did you ever solve this problem? I am also having trouble getting my camera to take an external trigger when using VideoDevice rather then videoinput.
Andy

Sign in to comment.


Sean de Wolski
Sean de Wolski on 5 Feb 2014
Use the 'TimerPeriod' option in the videoinput object.
imaqhelp videoinput

Shankar Subramanian
Shankar Subramanian on 13 Oct 2015
Hi Quentin and Andy,
While using VideoDevice System Object with gige cameras, you need to use the "DeviceProperties" field which consists of device specific properties (in this case Pointgrey blackfly) to specify the hardware triggering mode/condition.
deviceSpecificProps = vid.DeviceProperties
Browse through deviceSpecificProps and you will find the specific trigger properties that need to be set. An example from a display from another camera used through gige interface is shown below.
....
....
FrameStartTriggerActivation = RisingEdge
FrameStartTriggerDelayAbs = 0
FrameStartTriggerMode = Off
FrameStartTriggerSource = Line1
....
....
HTH,
Shankar

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!