PDA

View Full Version : Sink and DeNoise Filter



Bestbier
December 18, 2005, 15:37:59
I have a app that shows life video.

It has overlays on the device path which work well.

I have got the Denoise filter to work in the device path, but this slows the live video display which I don't want.

As I understand the documentation, I can show the live video on the display with the overlay and then apply the denoise filter to the sink path and then save bitmaps from the sink with the overlay on it.

I cannot get the filter to work on the sink path - Don't understand how to use apply settings to the sink path fully.

I have looked through all the samples.

I also need to know how to save images from the sink path and maybe displaying them in place of the live video for 1 second.

If anyone can point me in a direction or help

Thank you for your time.
Bestbier

Stefan Geissler
December 19, 2005, 10:41:16
Hello Bestbier,

here we go :-)

First of all, you must declare a FrameHandlerSink object and a FrameType object. You should do this on top of your form:


' Declare the FrameHandlerSink and the Memoryformattye for the sink.
Dim TheSink As New FrameHandlerSink
Dim TheFormat As New FrameType

The next form global object is the FrameFilter object, that will contain the DeNoise filter


'Declare the DeNoise filter
Dim DeNoiseFilter As FrameFilter

In the Form_Load sub we want to adjust the created FrameHandlerSink, assingthe color format to the sink and load the DeNoise FrameFilter.

In the first step setup the frame filter sink with the color format and assign it to the ICImagingControl object:


' Set the memory color format to Y800.
TheFormat.Type = "Y800"
' Add this format to the FrameHandlerSink.
TheSink.FrameTypes.Add TheFormat

' Assign the FrameHandlerSink to the ICImagingControl object.
.Sink = TheSink

In the second step load the DeNoise frame filter and assign it to the sink:


' Retrieve the denoise filter.
Set DeNoiseFilter = .FrameFilterCreateString("DeNoise", "")
If DeNoiseFilter Is Nothing Then
MsgBox "Failed to load the DeNoise filter!"
Else
' Add the denoise filter to the sink
.Sink.FrameFilters.Add DeNoiseFilter
End If

Now the FrameHandlerSink is created and setup and also the DeNoise frame filter should be loaded and inserted into the sink. You can call "LiveStart" now.
The sub for image snapping and saving looks like follows:


Private Sub cmdSaveImage_Click()
TheSink.SnapImage 1000
TheSink.LastAcquiredBuffer.SaveAsBitmap "Test.bmp", ICY800
End Sub

The saved bitmap has much less noise than shown on the live video. But if you have some fast movements, the moving object is blurred. This is a consequences from the image integration algorithm.
You may also insert the OverlayBitmap in the device path, so the complete Form_Load looks like follows:


Private Sub Form_Load()
With ICImagingControl1
On Error Resume Next
' Try to restore the last used video capture device.
.LoadDeviceStateFromFile "device.xml", True
If .DeviceValid = False Then
.ShowDeviceSettingsDialog
End If

If .DeviceValid Then
.SaveDeviceStateToFile "device.xml"
.MemoryCurrentGrabberColorformat = ICY800

.OverlayBitmap.Enable = True
.OverlayBitmap.ColorMode = OVERLAY_COLORMODE_GRAYSCALE
.OverlayBitmap.DrawText RGB(255, 255, 255), 20, 20, "Hello World!"

' Set the memory color format to Y800.
TheFormat.Type = "Y800"
' Add this format to the FrameHandlerSink.
TheSink.FrameTypes.Add TheFormat

' Assign the FrameHandlerSink to the ICImagingControl object.
.Sink = TheSink

' Retrieve the denoise filter.
Set DeNoiseFilter = .FrameFilterCreateString("DeNoise", "")
If DeNoiseFilter Is Nothing Then
MsgBox "Failed to load the DeNoise filter!"
Else
' Add the denoise filter to the sink
.Sink.FrameFilters.Add DeNoiseFilter
End If

.LiveStart

End If
End With
End Sub


I have attached the project to this post.

Bestbier
December 19, 2005, 10:52:24
Hi Stefan

Thanks for all the help - much appreciated.

Just one more question: How do I set the amount of frames the filter does in the sink. I not sure about this.

Regards
Bestbier

Stefan Geissler
December 19, 2005, 11:21:41
Hello Bestbier,

With the list returned by


DeNoiseFilter.AvailableParameters

you query a list of the parameters that are exposed by the filter.
(http://www.imagingcontrol.com/ic/docs/html/activex/prop_descFrameFilter_AvailableParameters.htm)
The only parameter of the DeNoise filter is "DeNoise Level". You can set the parameter with following lines of code:


DeNoiseFilter.BeginParameterTransfer
DeNoiseFilter.Parameter("DeNoise Level") = 2
DeNoiseFilter.EndParameterTransfer

The "2" is the number of frame to be integrated. You can try different values for this parameter. For parameters of frame filters refer also to: http://www.imagingcontrol.com/ic/docs/html/activex/prop_descFrameFilter_Parameter.htm

Bestbier
December 19, 2005, 15:29:38
Thank you very much.

All working beautifully now!

Will only have to add a short delay before save funtion is called to not get a blurred image. Object moves then operator stops it and saves a image.

Regrads
Bestbier