!! HELP !! Extracting frames in a video and comparing them THANKS ALOT!

Hi,
I need help in my project here. my project mate did this in C++, which no one else in the grp knows and so i need some help if anyone knows how to convert it to VB, if possible.

The program is supposed to pick up a unattended object (like a bomb) and send an alarm (to like SMS or a PC). so it works like that. (what i understand he said, & seeing the C++ code).

  1. capture a background
  2. start capturing video
  3. average frames (eg. 10), so small movement is not picked up (think so)
  4. if pixels are the same for too long ( xx frames) - something isn't moving then send alarm
he used C++ and open CVhttp://www.intel.com/technology/computing/opencv/,http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/index.html
the things needed are a digital camera and a laptop(PC) for your info. if it can be reduced it will be good also, but i don't think so.if the (C++)code is needed i can post it but its very long

i found a site that is very useful -http://www.codeproject.com/useritems/ExtractVideoFrames.asp but i still am not so clear about it, i am tring that but hopefully someone here can help. also i still need to know how do i compare bitmaps (the pixels)

Any help is appreciated

[1936 byte] By [IceAngel89] at [2007-12-28]
# 1

IceAngel89,

It seems that your project is rather complicated. According too your description, I guess you are not familiar with the Bitmaps and Pixels with the comparison. Am I right? In your project, I think the Windows GDI needs the Device-Dependent Bitmaps, you can have a look at the following link: http://msdn2.microsoft.com/en-us/library/ms532313.aspx

When you capture a background, there is stilll a problem related to the Pixel, which means the DPI of the screen. This link will help you to better understand this: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/highdpi.asp

Finally, the Pixel Reference is necessary for your project, please view this link shows the useage of Pixel Reference:

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/highdpi.asp

BrunoYu-MSFT at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2
Hey, Bruno thanks i was starting to give up thinking no one would answer this.
I read the articles, but that means i can't do that in VB? Actually, i saw some articles about DirectX capture class? dunno if its a custom class. But its like something to extract frames etc.
IceAngel89 at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 3

IceAngel89,

How is your problem going? I hope you have solved it :-) Actually, you can try some third-party tools to help you to extract frames in a video and compare.

BrunoYu-MSFT at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 4
Just thought I'd mention this one: have a look at AviSynth - it's a frameserver and you can use it to serve single frames or whole movies in a mediaplayer or a directshow graph. It uses .avs scriptfiles which should be easy to write via code and also edit manually at the same time. And I'm sure it has some powerful functions for comparing frames, as that's important when doing video-encoding which is what it's mainly used for.
nogChoco at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 5
Hi, i think i have exceeded the time for this project, so no rush to do it now, But, i also want to learn anyway. and thanks. I will try what u have said. and anyone knows if it is possible to use Microsoft class libraries like IPhotoAcquire or DirectX. was just wondering. cos i saw some articles on MSDN about them and their methods. About how is this going, i will be going with the project mate's C++ code, which i dunno if it works. Currently working on my VB and HTML projects. due in 1 to 2 weeks time.(This post is for a Creative Thinking Project.) after that i can work on some leisure projects, maybe to build up my portfolio. And THANKS!
IceAngel89 at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 6
Maybe i need your help again, err.... i know this is difficult, but anyway, i found that

DirectInput - can be used to get data from input devices

http://msdn.microsoft.com/archive/default.asp?frame=true

DirectShow - can be used to stream video http://msdn.microsoft.com/archive/default.asp?frame=true

But the problem, how do i use them? can they be used in VB or only C++.

I am trying AviSynth now. anyone knows if AviSynth can access data fm Web Cams?

IceAngel89 at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 7
Here's a very basic example of using DirectShow as a mediaplayer:

- Add a reference to the (COM) ActiveMovie Control Type Library (or to the c:\Windows\System32\quartz.dll)
- Now you will see the Interop.QuartzTypeLib in your Object Browser (press F2). There you'll find the objects you can use.

The main object for handling DirectShow, is the FilGraphManager. You create that, and then point the other interfaces at it. The FilGraphManager has its own window, but you can bind it to a control on your form, and you can also link a control as a 'sink' to handle the click-events that occur on the DirectShow videowindow.

The code below has a working example for showing a DirectShow video inside a panel on a form. The panel will be the sink for the DirectShow video, and simply switch back and forth between fullscreenmode. It's a very basic example, though.

Note that AviSynth is a frameserver that uses .avs scriptfiles. If you tell a mediaplayer to open an .avs file, then AviSynth steps in, reads the .avs script that points to two moviefiles joined together for example, and then feeds the mediaplayer each frame in the joined moviefiles. The Mediaplayer doen't know that, and simply thinks it's showing a normal moviefile like an .avi or .mpg.

DirectShow is a mediaplayer, but also has the stuff that AviSynth can do (like applying filters to the video), but I thought it was a bit more complicated to get DirectShow filters set up, than to simply write scripts for AviSynth, so I never looked into DirectShow filtering.

I don't know about direct webcam-capturing, but I'm sure it'll be possible if you delve a little deeper into it than I have:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/directshow.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/filtergraphmanager.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/controllingthefiltergraphinvisualbasic.asp


Imports QuartzTypeLib

Public Class Form1
Public zFGM As FilgraphManager
Public zVideo As IBasicVideo2
Public zAudio As IBasicAudio
Public zPosition As IMediaPosition
Public zWindow As IVideoWindow


Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' New DirectShow and link it to a Panel1
zFGM = New FilgraphManager
zVideo = zFGM
zAudio = zFGM
zPosition = zFGM
zWindow = zFGM

' Open an AviSynth script that returns two joinedmovies as one movie:
' point it at an .avi file if you want to keep it simple first
zFGM.RenderFile("c:\Temp\JoinedMovies.avs")

' Remove the FGM's own WindowFrame and Scrolling
' and set the new owner as Panel1 which is also the
' handler for events generated by the FGM
zWindow.WindowStyle = CLng(&H6000000)
zWindow.Owner = Me.Panel1.Handle
zWindow.MessageDrain = Me.Panel1.Handle

' Resize the window to the Panel's size and location
' note that the video will stretch but you can write code for
' applying the right aspect via zVideo.DestinationPosition
Dim zSize As Rectangle = Me.Panel1.ClientRectangle
zWindow.SetWindowPosition(zSize.Left, zSize.Top, zSize.Width, zSize.Height)

' Start the movie
zFGM.Run()

End Sub


Private Sub Panel1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp
' toggle FullScreenMode
If zFGM IsNot Nothing Then
zWindow.FullScreenMode = Not (zWindow.FullScreenMode)
End If
End Sub

End Class


The AviSynth JoinedMovies.avs scriptfile that I used for this - note that framesizes and other stuff like frames/second must be the same, so it's best to try with a movie you've split first. Or only try it with 1 and have the script return only aMovie. Note that DirectShowSource can be a little picky about certain types of videofiles - you may have to specify the framerate yourself in the DirectShowSource command - check AviSynth's FAQ on it if you're getting that error.

aMovie=DirectShowSource("c:\zTemp\aMovie.wmv")
aMovie=BilinearResize(aMovie,512,288)
bMovie=DirectShowSource("c:\zTemp\bMovie.wmv")
bMovie=BilinearResize(bMovie,512,288)
return aMovie+bMovie

nogChoco at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...