-
Jul 27th, 2007, 02:05 PM
#1
Thread Starter
Addicted Member
read image intensities [VB.NET2005]
I'm working on a program that will read from a webcam, and be able to find the "light" spots on it. It's going to be used in a multi-touch input program, where the field in the camera is basicly black (except for average noise) and when a finger is pressed down the camera now will see a bright white spot. So I guess my question is, when i load the image from the camera in to VB.NET, what is a good way to go about finding the location of this bright spot? I would like to have it running around 10-15 FPS so speed is a big issue. Anyone got an idea?
-
Jul 28th, 2007, 09:28 AM
#2
Junior Member
Re: read image intensities [VB.NET2005]
If you want to find a bright spot, or a dark spot for that matter, what you can do is read the average RGB values for each of the pixels in your image. You could use something like 'GetPixel()' and then AVG = (color.r + color.g + color.b) / 3. The closer the value 'AVG' is to 255, the 'whiter' that your pixel will be.
-
Jul 29th, 2007, 06:29 AM
#3
Lively Member
Re: read image intensities [VB.NET2005]
hey MotoMan_Yz400, few days back i was also trying to do somwthing like that... i also like to know something about it...
i did a search and got the webcam viewer: http://www.vbforums.com/showthread.php?p=2048466
this class will help us to get the pictures in the picturebox... and after having the pictures we can get what capnyoaz said...
-
Jul 30th, 2007, 08:27 AM
#4
Thread Starter
Addicted Member
Re: read image intensities [VB.NET2005]
well my concern is speed. Even having a the web cam running at 320x240, thats still 76,800 pixels to read and setting up a FOR...NEXT loop would only yield a frame a second if i'm lucky. Can GetPixel() run through a memory load picture? In hopes to have it run faster? Like I said in my last post, I would like (if at all possible) 10 FPS.
-
Jul 30th, 2007, 01:28 PM
#5
Frenzied Member
Re: read image intensities [VB.NET2005]
GetPixel is pretty fast. Try the loop and see how it goes. Also, maybe you can use SetTimer to run the loop every 5 or so seconds.
-
Jul 30th, 2007, 10:04 PM
#6
Junior Member
Re: read image intensities [VB.NET2005]
GetPixel is slower than a dead turtle. If you really want to get some good speed, what you need is to access the memory directly and read it byte by byte. If you are familiar with the .Lockbits method that is the ticket. If not, check out this article, it should explain everything you need to know about it. If you still need more help, let me know and I will write a demo app for you.
http://www.bobpowell.net/lockingbits.htm
Good Luck!
-
Jul 31st, 2007, 10:34 AM
#7
Thread Starter
Addicted Member
Re: read image intensities [VB.NET2005]
capnyoaz your right, you can go grab a cup of coffee waiting for one frame to be analyzed. I ran a simple 2 layered FOR...Next loop and average 1.6sec per frame with an image 320x240. So thats 5/8ths of a frame per sec. I'm looking at something 16 times faster minimum. But i'll look into that, thanks capnyoaz.
-
Jul 31st, 2007, 10:32 PM
#8
Re: read image intensities [VB.NET2005]
Definately need LockBits and a Marshall copy. Since its VB you can't have a direct memory pointer.
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 1st, 2007, 09:50 AM
#9
Thread Starter
Addicted Member
Re: read image intensities [VB.NET2005]
Well I have the LockBits running right and can return a memory pointer for the bitmap itself. However I cant get the Marshalling to function correctly. I'm stuck on actually retrieving the byte data from memory. I looked through the help files in my VB.NET Express and it didnt return much that pertains to what I'm doing. I also read a few tutorials on how to do it, but the sample code they give (supposed to be in Vb.Net) doesn't seem to work. Anyone tried this?
-
Aug 1st, 2007, 04:34 PM
#10
Junior Member
Re: read image intensities [VB.NET2005]
Post some code and I will take a look at it for you. Are you getting specific errors, or is nothing happening?
-
Aug 2nd, 2007, 08:39 AM
#11
Thread Starter
Addicted Member
Re: read image intensities [VB.NET2005]
No it's more like I never done this before. The code I do have, not sure if it's doing what i want, but it's atleast not throwing an error. As far as the marshalling, dont know even where to start. I'll have some code up later today.
-
Aug 2nd, 2007, 10:01 AM
#12
Thread Starter
Addicted Member
-
Aug 2nd, 2007, 11:51 AM
#13
Junior Member
Re: read image intensities [VB.NET2005]
That my friend is a very good question indeed. Image recognition is a tough subject, and I've only ever done a tiny bit, and it wasn't very sophisticated. Now I have no idea what your image looks like, but as a starting point I would recommend measuring the extremes of your 'dots'. You know, left, right, top and bottom. This will give you a rectangle, and then you can get the center from there. Of course, this may not work at all, so best of luck to you.
-
Aug 2nd, 2007, 11:59 AM
#14
Thread Starter
Addicted Member
Re: read image intensities [VB.NET2005]
Well below is my test image. I was thinking one of two ways to go about it. The first being as you said (alittle more "thinking" intensive on the computer) which would be good for a object interface. The second being (as you see those people doing those "dust in the wind" samples kinda like this http://www.youtube.com/watch?v=DQ-N2...elated&search= ) I'd just look for anything over a specified intensity and use those pixels for modification. I'll have a small sample of the latter posted up later today, if not tomm.
Last edited by MotoMan_Yz400; Aug 2nd, 2007 at 12:05 PM.
-
Aug 10th, 2007, 03:35 PM
#15
Thread Starter
Addicted Member
Re: read image intensities [VB.NET2005]
well i have the program working now. It uses a recursive method to locate each blob then records the min and max of each blob. I'm using the getpixel method, and it get about 1 FPS. Now going to re-write this code using the marshal class. should run it upward of 30-80fps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|