I’m writing to let you know that I’ve managed to convert Touchless to run in WPF using Jeremiah's MediaKit.
Here you can download the modified sources for both Touchless SDK and WPF MediaKit:
Here is a brief list of changes that I made:
Modified VideoCapturePlayer to include SampleGrabber in filter graph. It uses the same properties as the video stream so the output bitmap will most likely be 24bpp RGB.
VideoCaptureElement exposes Click method that captures a single frame and some additional properties.
I have removed all dependencies on the WebCamLib, including the Camera class and all related code from TouchlessMgr.
The camera updates are now handled in the demo application via the CameraTracker class which manages its own thread.
TouchlessMgr.UpdateMarker now writes to separate bitmap to create marker highlights. This bitmap is later overlayed on top of the video via an InteropBitmap.
Since the input bitmap now can have 24 bpp the code that accessed BitmapData via pointers was moved to BitmapHelper class that can handle both 24 and 32 bpp. This also removed the need to convert the input bitmap
with GetThumbnailImage which in turn improved performance.
I have changed all marker position properties to double type so it can size more smoothly in WPF.
The video now can run in 640x480 resolution. Some changes were made in order to avoid repeating memory allocation of large arrays.
The overall performance is pretty good – I get 30fps on 640x480 video with about 23% CPU. I think some overhead is caused by WPF redrawing the overlay bitmap. But another cool idea would be to
rewrite the algorithm using Parallel Extensions.
Hope you enjoy my sample, and please let me know if you have any suggestions or ideas what can be improved.