[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

Dealing with Vermin

And for those of you who don't visit the Lounge on a regular basis, please read this first:
http://www.experts-exchange.com/Miscellaneous/Lounge/Q_21222015.html

Now then, I've had an idea. And I would like to get some input from you experts. Now I realise that this is a solution that will come in many parts, and I'd like to reward each contribution separately. I will therefore leave this question at the bare minimum of points, will post "points for" questions for every suggestion contributing to the solution.

What I am looking for is this:

1) A programatic approach toward capturing images from a PC Cam. Please do not post 3rd party tools here, I am looking for vanilla VB code that goes and gets the image directly from the camera, if necessary through API calls.

2) Secondly some suggestions toward "motion sensing". My idea was to take the images in sequence, divide them into, say, nine sub-images and if more than one (two, three?) sub-image is different from before I will treat that as motion occurring and will act on this. My guess is that this would be sufficient to avoid it recording the slow brightening and darkening of the image due to the changes in daylight during the day, but it should pick up the drastic changes from something appearing in front of the camera.

Cheers

Pino
0
WernerVonBraun
Asked:
WernerVonBraun
  • 8
  • 4
1 Solution
 
WernerVonBraunAuthor Commented:
With regard to the image capture I guess perhaps some TWAIN-based mechanism would be appropriate? That way it could even handle multiple cameras?
0
 
WernerVonBraunAuthor Commented:
Hum...

Looks like I'm barking up the wrong tree with TWAIN - it invokes some interface that I cannot get rid off. I need to directly access the Cam's output.

Back to square one....

Is anyone actually reading this or am I talking to myself?
0
 
WernerVonBraunAuthor Commented:
Found Ray Mercer's vidcap project. Impressive. Only thing is I realise there is no way I can do movement sensing with this. I pointed cam at blank wall and took two separate pictures. They're different. You get two bitmaps of the identical image, and their CRCs are totally difficult. Camera keeps readjusting exposure and so on changing the picture constantly....

Hi ho hi ho....
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Erick37Commented:
You're looking at noise in the picture.

Difficult subject, but let's have some fun.  You'll have to do some image processing to clean up the images a bit: apply a soften effect to reduce noise, convert to grayscale, and maybe increase the contrast somewhat.

Now compare 2 images taken at different times. Reading the differences of 2 images is relatively easy:

1) Grab and process 2 images as above.

2) Use StretchBlt to copy the first image to a picturebox using the SRCCOPY rop code while scaling it down to a smaller size, maybe 64 x 64 pixels.

3) With the second image, use StretchBlt to the same picturebox as above, but with the SCRINVERT rop code.  Also scaling down to the same size as above.

4) The resulting picture will be black where the pixels are identical, and gray or white where the pixels are different.  Loop the pixels in the picture and keep count of the non-black pixels.

That is the most basic approach.  But don't blame me if the cops show up at your door because the sun came out from behind the clouds!

:-)
0
 
WernerVonBraunAuthor Commented:
Nice one, Erick - I do grok the ol' blittin' gig so I think you may be on to something.

I guess then the trick with the "motion detection" is to go for distinctive changes in the image. If the double-blit result from your suggestion there is a fairly uniform *grey* rather than *black* you can still assume that all that happened is, like you suggested there, a sudden brightening or darkening of the whole image due to weather conditions. If an *area* of the image turns grey/white while the rest remains pretty much black/grey, we have real movement on our hands.

This sounds promising and I shall investigate. If it works.... I have 550 points to play with and I dare say some of those may be on their way to you, my son....
0
 
WernerVonBraunAuthor Commented:
By Jove Erick. You really do appear to have hit the jackpot there old boy.

That StretchBltting does do the job alright, and if you reduce the size to 64x64 it's pretty much uniform black until you move.

Still, a little bit of flickering - what about that "softening" and "contrast" stuff you were talking about. How does one go about doing that then?
0
 
Erick37Commented:
Interesting reading here about 3/4 way down the page in the section marked:

"1 – Motion Detection and Tracking"
http://www.gameprog.it/advise_redirect.php?url=http%3A//www.gamedev.net/reference/articles/article2007.asp

Seems that applying the lowpass filter after the comparison is a better idea in detecting changes, and will obviously run faster on smaller images.


I'm sure you're aware of vbAccelerator's image processing sample, and the section on sharpening / blurring:

http://vbaccelerator.com/home/VB/Code/vbMedia/Image_Processing/Blurring__Sharpening_and_Embossing/article.asp


I'll look into how to perform a lowpass filter using GDI+ tonight, if I have the energy...

0
 
WernerVonBraunAuthor Commented:
That first link is a gem, Erick. It should do quite nicely, thanks....
0
 
WernerVonBraunAuthor Commented:
Sorry Erick, we've had a very sick baby over the weekend. Suffice to say that the last thing on my mind was playing with software. Will keep you posted.

Pino
0
 
Erick37Commented:
No hurry.
Hope the little one feels better.
0
 
WernerVonBraunAuthor Commented:
Still haven't had a chance to look but in fairness you have given me a lot to go on.
0
 
Erick37Commented:
Thanks Pino,

Here's a link to another packaged solution which I have on my holiday list.  The Linksys wireless internet camera with integrated motion detection:

http://www.linksys.com/products/product.asp?grid=33&scid=38&prid=650
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 8
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now