AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Video Recording

The forum is to discuss topics related to different areas of image processing and computer vision.

Video Recording

Postby smaeusle » Mon Feb 23, 2009 6:26 pm

Hey my Name is Sascha Maeusling and I am new with C# and the whole Video processing topic.
I have to write a program wich is able to detect Motions from a video and cuts out these parts of a video where no Motion is detected. I have a closer look at the examples but i wasn't able to create an avi writer which is able to to that. I create one and try to record every Lastframe from the camea Object. But i dont know where to add the frame to the avi file. I thought i have to do this in the "camera_NewFrame" Routine. but there i have no acces to the camera object. Can somebody help me with this problem?
smaeusle

edit\ now i found a way to record my video but i have an other issue. Is there a possibility to go back in the video ?
Because if i have found a motion iwant to save some frames before and after a motion has happend. or do i have to save every single frame to do something like that?
smaeusle
 
Posts: 5
Joined: Mon Feb 23, 2009 6:01 pm

Re: Video Recording

Postby andrew.kirillov » Tue Feb 24, 2009 8:58 am

Hello,

smaeusle wrote:I thought i have to do this in the "camera_NewFrame" Routine. but there i have no acces to the camera object.

The NewFrame event is the right place. In the event handler you will get the NewFrameEventArgs, which contains a Frame property - this is a new video frame, which needs to be saved.

smaeusle wrote:Is there a possibility to go back in the video ?

It depends. Let's suppose you have an IP camera, or USB camera. Can you rewind video back in time? :? I don't think so. It could be done for video files ... Anyway this is not something, which is covered by AForge.NET Framework - it relies mostly on video feeds from cameras and sources like this, which you cannot rewind.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3434
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Video Recording

Postby smaeusle » Tue Feb 24, 2009 6:06 pm

Hallo again,
Thank you for zour fast response.
I dont use a Camera, its a normal Avi file. Thats why i thought there maybe is something like a function which sets back the current stream for a specific number of frames.
smaeusle
 
Posts: 5
Joined: Mon Feb 23, 2009 6:01 pm

Re: Video Recording

Postby andrew.kirillov » Tue Feb 24, 2009 6:51 pm

Hello,

Well, if you use AVIReader class to process your videos, then you may use its Position property. But other classes, which implement IVideoSource interface, don't provide such feature, since the interface is generic and also aimed for cameras.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3434
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Video Recording

Postby smaeusle » Tue Feb 24, 2009 10:40 pm

I use the IVideoSource but with a few tricks i managed to handle it know.
Sry to ask another stupid question but, after analysing one video will go on with another. But i have a Problem implemeting this. There is now Event or something like that which singnals me that the video reached his end so that i can open the next file. At the Moment i have all the different pathes in an array the only thing which is missing is the Moment i have to open it.
i tried to us the Attribut Camera.isRunning , but if i know run the Apllication i always get an error message. Is there another way without changing the camera class?
Also i have tried to use the waitforstop method. but if i use this one he don't start to play the video.
smaeusle
 
Posts: 5
Joined: Mon Feb 23, 2009 6:01 pm

Re: Video Recording

Postby andrew.kirillov » Wed Feb 25, 2009 10:25 am

Hello,

You may try using FileVideoSource instead of AVIFileVideoSource. The AVIFileVideoSource is looping video so after it reaches end of video file it starts again. But the FileVideoSource does not do so, so you may catch the moment when it stops.

I will rework the AVIFileVideoSource class, so it has the same behaviour.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3434
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Video Recording

Postby smaeusle » Wed Feb 25, 2009 7:18 pm

Ok thanks for that hint, now i have implemented it with a timer because i know the lenght of the videos, but i think that this isn't the best solution. I think the great advantage of the normal FileVideoSource is that it playes the Video with his real framee rate. So the duration for the play is more predictable.
smaeusle
 
Posts: 5
Joined: Mon Feb 23, 2009 6:01 pm

Re: Video Recording

Postby andrew.kirillov » Wed Feb 25, 2009 9:03 pm

Actually FileVideoSource's thread should stop, when video is finished. So you may use IsRunning property or WaitForStop() ...
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3434
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Video Recording

Postby smaeusle » Wed Feb 25, 2009 9:56 pm

Thanks for your help no i am finished with the first version of the application.
Because i have never done something like that before, i have some other questions. I tried to create an installer for my programm to run it on other machines then my own one. I trief different pograms to do that. But I after installing it on another Maschine the Program doesnt work and starts with an exception which forces the program to shut down. Is there anything special i have to do? Or is it a neccessary requirment that your libary is installed on concerning Computer?
regards
smaeusle
 
Posts: 5
Joined: Mon Feb 23, 2009 6:01 pm

Re: Video Recording

Postby andrew.kirillov » Wed Feb 25, 2009 10:10 pm

The AForge.NET Framework, as well as your application, requires .NET Framework. So you need to make sure the target PC has the version of .NET Framework you need. Other than that I don't know what are other requirements of your application.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3434
Joined: Fri Jan 23, 2009 9:12 am
Location: UK




Return to Image Processing and Computer Vision