PDA

View Full Version : parallel live video capture and image grab



haaver
March 8, 2007, 15:49:00
Hallo,

currently I implemented live video capturing and also want to be able to
grab a picture randomly while the recording is done (in parallel).

One Framefilter (rotation) is inserted into the device path.
Inside the sink path I use a mediastreamsink to save the video.
During the recording process imagebuffers aren't available (exceptions).
So, I guess I have to implement an extra framehandlersink and also insert
it into the sink path. Herein the images can be grabed and saved.
Also here aditional image processing can be made.

But now the question: How can both sinks be implemented (using VB.NET).

\Sven

Stefan Geissler
March 8, 2007, 16:10:39
Hi Sven,

Short answer: See here:
http://www.imagingcontrol.com/library/dotnet/section/image-aquisition/example/image-and-avi-capture/

haaver
March 8, 2007, 17:08:54
Thank you.

That's nice and good. I hope the filter used herein can also be inserted into
the sink path, not only into the device path.
How can I extend or write my own filter? There is a Frame Filter Class Wizard
online available. But I couldn't find the Add IC Frame template. Where is it located?

\Sven

Stefan Geissler
March 9, 2007, 08:14:05
Hi Sven


That's nice and good. I hope the filter used herein can also be inserted into
the sink path, not only into the device path.

I can be used in the all paths.



How can I extend or write my own filter? There is a Frame Filter Class Wizard
online available. But I couldn't find the Add IC Frame template. Where is it located?

This can be done C++ or C# only. VB does not support pointers, thus you wont get access to the image data. For creating own filters in C# please refer to:
http://www.imagingcontrol.com/support/documentation/dotnet/Binarization.htm

haaver
March 12, 2007, 10:15:30
Hallo Stefan,

a new sink is always instaziated (declared) as a "New" one.
Additionaly a frame filter is inserted as new into the mediastreamsink.
Every time a video is stopped and started anew, a new instance
is created for both. Do I need to care about memory handling for these?

haaver
March 12, 2007, 13:12:48
Hi Sven,

Short answer: See here:
http://www.imagingcontrol.com/library/dotnet/section/image-aquisition/example/image-and-avi-capture/


short question to this: This example does not seem to work with a
mediastreamsink including, e.g. binarization filter.
The debug error message when executing
SetStringParameter("ImageName", imgName):
System.ArgumentException was unhandled
Message="Value does not fall within the expected range."
Source="Interop.ICImagingControl3"
Is that right?

Stefan Geissler
March 13, 2007, 08:46:35
Hello Sven,

before I start to enhance a sample, just one question:
You want to use a filter chain with
1.) binarization filter
2.) SaveImage filter

and capture AVI?
Is this correct?
Also I would like to know in which path the filters are to be inserted and why you choose these pathes:
1.) Device
2.) Display
3.) Sink (AVI)

The SaveImage filter can be placed in the path of your wishes, because it does not change the image. The binarization filter changes the image, thus its location can change the expected results.

Thank you.

haaver
March 13, 2007, 09:37:21
Ok, the I explain my problem in detail.
The fw camera pixel size is fixed to 1280x960, but too big for videos,
but good for single images.

So in summary I need to resize the video to a quarter, but keep the
images during video recording at original size. Additionally, videos need
to be cut once in a while, they are around 30 seconds to 10 minutes.

To get out an optimal view, the camera is rotated by 90 degrees,
therefore I need the rotation filter in the device path --> working.

The display path got no filters, because it's only for controlling once
in a while. But the view is scaled down to fit in a smaller window.
(can this be switched off after a while and resumed by a mouse click?
I couldn't get that working either.)

Yesterday, I experimented with avicapture and binarization filter without
success.
This filter needs to scale down the video.
Can the size property be changed within the IFrame?

The other filter "Save Image" is needed to grab the images during
video recording. Both of them (binarization --> resize and save image)
are put into the sink path.

\Sven

Sascha Schmidt
March 13, 2007, 16:29:10
Hallo,

Here is a sample program, which shows a solution for your problem.
A "ScalingFilter" is attached.

Step1: Place the "rotation filter" in device Path.
Step2: Create an instance of the "ScalingFilter".
Step3: Place the "Save Image filter" in Display Path.

That's it!
Images are rotated in Device Path.
The scaled and rotated video is saved to a avi, if the "ScalingFilter" is placed in the aviSink.
A full size image is saved to a jpeg file using the SaveImage filter.


public partial class Form1 : Form
{
TIS.Imaging.FrameFilter ScalingFilter;
TIS.Imaging.FrameFilter RotationFilter;
TIS.Imaging.FrameFilter SnapFilter;

private TIS.Imaging.MediaStreamSink aviSink;
private TIS.Imaging.BaseSink oldSink;

TIS.Imaging.AviCompressor AviCodec;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

icImagingControl1.ShowDeviceSettingsDialog();

if (icImagingControl1.DeviceValid)
{
ScalingFilter = icImagingControl1.FrameFilterCreate("ScalingFilter");

RotationFilter = icImagingControl1.FrameFilterCreate("Rotate Flip");
RotationFilter.ShowDialog();
SnapFilter = icImagingControl1.FrameFilterCreate("Save Image");

icImagingControl1.DeviceFrameFilters.Add(RotationF ilter);
icImagingControl1.DisplayFrameFilters.Add(SnapFilt er);

foreach (TIS.Imaging.AviCompressor Codec in icImagingControl1.AviCompressors)
{
if (Codec.Name == "MJPEG Compressor")
{
AviCodec = Codec;
break;
}
}

icImagingControl1.LiveStart();
}
else
this.Dispose();

}

//Record Avi
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "Rec Avi")
{
button1.Text = "Stop Rec";

ScalingFilter.SetBoolParameter("Interpolation", true);
ScalingFilter.SetFloatParameter("Binning Factor", 0.1f);

aviSink = new TIS.Imaging.MediaStreamSink();
aviSink.FrameFilters.Add(ScalingFilter);

aviSink.Codec = AviCodec;
aviSink.Filename = "test.avi";
aviSink.SinkModeRunning = true;

icImagingControl1.LiveStop();

oldSink = icImagingControl1.Sink;
icImagingControl1.Sink = aviSink;

icImagingControl1.LiveStart();

}
else
{
button1.Text = "Rec Avi";

icImagingControl1.LiveStop();

aviSink.SinkModeRunning = false;
icImagingControl1.Sink = oldSink;
aviSink = null;

icImagingControl1.LiveStart();

}
}

//Save jpeg
private void button2_Click(object sender, EventArgs e)
{
SnapFilter.BeginParameterTransfer();
SnapFilter.SetStringParameter("ImageName", "image.jpg");
SnapFilter.EndParameterTransfer();
}

}

haaver
March 14, 2007, 15:03:14
Thank you very much. This example finally worked out.

The provided resize filter is not really included inside ICImaging (3.0.1).
Do you have any small document describing possible parameters for
the resize and save image filter?

\Sven

Sascha Schmidt
March 14, 2007, 15:39:25
Hi,

The ScalingFilter is especially developed for your issues.

Parameters:
"Interpolation" enables the scaling .
"Binning Factor" sets the scaling factor.