Click here to Skip to main content
15,888,124 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, im making a program like that. If web cam detects any motion then i want to take picture of this motion. I finished the program but i need just get that image. There is a picture from my project. After message box shows you "motion is dedected" when user click "Tamam" > "Okay"
then screen will be save.

http://prntscr.com/4syrrq

i wanna take the picture (behind the messagebox) as you can see.

Thanks.

ps: sorry for my bad english.
Posted
Comments
[no name] 4-Oct-14 11:32am    
http://www.bing.com/search?q=c%23%20save%20image use whatever method fits your project.
[no name] 4-Oct-14 12:00pm    
Taking _a_ Picture of a motion sounds critical. Why? Picture is at t, motion is t -t0 + t1.
Afzaal Ahmad Zeeshan 4-Oct-14 17:15pm    
On the computer state I mean, on the state where you are going to handle the code block. A slight change in the pixel amount is going to execute the command. Are you sure you wanna do it?

There is an article on CodeProject that explains how you can get the difference between two images. While you're having a look at the camera screen, you're watching images being changed as frames on the screen. Each of them in real are frames being provided to you.

So, each frame might differ to the previous one in many ways. Simple image comparison in .NET[^] explains how you can get the difference.

In that article, he explains that on the byte level (pixel level) each pixel has a slight difference that human eye can never even think about noticing. So you might not detect any change but the computer would find a change in the new image and will "Click! Click! Click!" in 3rd part of the second and so.

Read the article above, and code it out for you. All you need to do is, to make sure, that the image difference is being handled. After that you can get the pixels from the screen and saved as a screenshot. I have written a tip for that, Saving a Screenshot Using C#, A.K.A "Console Monitor"[^], here you go. Read these both links, and I hope you will get what you want to get.
 
Share this answer
 
Hello,

To be able to take snapshots when any motion is detected, take a look the following code snippet.
(This is a short example from the full source code that can be found here:
How to handle alarms by taking a snapshot and sending it as an e-mail in C#[^].)

By using this code you can create a snapshot (displaying the current date in the file name)
if any motion is detected. (As the previously mentioned example project focuses on sending this
snapshot in e-mail as an alarm notification, the insterted code snippet can be also used
and call the SendEmail() method that sends the snapshot automatically in e-mail.)

C#
private void _motionDetector_MotionDetection(object sender, MotionDetectionEvent e)
{
if (e.Detection)
{
InvokeGuiThread(() => label_Motion.Text = "Motion detected");

var date = DateTime.Now.Year + "y-" + DateTime.Now.Month + "m-" + DateTime.Now.Day + "d-" +
DateTime.Now.Hour + "h-" + DateTime.Now.Minute + "m-" + DateTime.Now.Second + "s";
var filename = "Camera_" + date + ".jpg";

Task.Factory.StartNew(() =>
{
var snapshot = _snapshot.TakeSnapshot();
_image = snapshot.ToImage();
_image.Save(filename);
SendEmail(filename);
});
}
else
InvokeGuiThread(() => label_Motion.Text = "Motion ended");
}


I hope it helps you to complete your issue.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900