Sign in to follow this  
Followers 0
Qwerty212

Pixelsearch help needed (not the pixel I'm looking for)

22 posts in this topic

#1 ·  Posted (edited)

Hello from Barcelona.

After looking on the forum I managed to do a pixelsearch on a transparent gui that can be resized.

The main problem is that I want pixelsearch to look for a black pixel, but I want the one that is more at the left of the searching rectangle (number 2 on the image), and pixelseacrh points to number 1:

Posted Image

This is my code, I've tried to change the coordenates but it worked even worst:

Case $msg = $Button9
$size = WinGetPos("minigui")
Sleep (10)
$coord = PixelSearch($size[0], $size[1], $size[0]+$size[2], $size[1]+$size[3], 0x000000, 30)
Sleep (10)
If Not @error Then
MouseMove($coord[0], $coord[1])
EndIf

It seems that it search from up to bottom instead of from left to right ;)

Any help pointing me what I'm doing wrong will be much apreciatted.

Greets from Barcelona

Edited by adolfito121

Share this post


Link to post
Share on other sites



Of course it is returning that pixel - PixelSearch, searches from left -> right and top -> bottom and normally it will find the first pixel on top row.

You will need to test pixel position and move to the next line - again and again until you find the pixel at the extreme left.

You will need to run your PixelSearch function in a loop and everytime the pixel is found, store his (x) position and increase $top parameter by 1 - you will get new coordinates, comapre the new (x) with the old one, if it is smaller than the previous one, keep it, increase $top again and so on until (x) is greater than the stored value.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hello Adolfito121,

This is a basic example of what I do when trying to attempt the same result:

Local $left_Region = 10 ;Left most point of region to check
Local $top_Region = 10 ;Top most point of region to check
Local $right_Region = 100 ;Right most point of region to check
Local $bottom_Region = 100 ;Bottom most point of region to check
Local $far_left_point = $right_Region+1 ;This is necessary for error checking
Local $bottom_point = $bottom_point+1 ;This is necessary for error checking
For $y = $top_Region To $bottom_Region
    For $x = $left_Region To $right_Region
        If PixelGetColor($x,$y)=0 Then
            If $x<$far_left_point Then
                $far_left_point=$x
                $bottom_point=$y
            EndIf
        EndIf
    Next
Next
If $far_left_point>$right_Region or $bottom_point>$bottom_Region Then 
    MsgBox(0,"Error","Black was not found in this Region")
Else
    MouseMove($far_left_point,$bottom_point)
    MsgBox(0,"Far Left Point","Far Left Point coord: " & $far_left_point & "," & $bottom_point)
EndIf

Hope it helps ;) Good Luck

Realm

Edit: Made the Error check at bottom just a bit better

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Of course it is returning that pixel - PixelSearch, searches from left -> right and top -> bottom and normally it will find the first pixel on top row.

You will need to test pixel position and move to the next line - again and again until you find the pixel at the extreme left.

That's what I was afraid about it, it's a part of the pixel search function to look from up to bottom.

Hello Adolfito121,

This is a basic example of what I do when trying to attempt the same result:

Local $left_Region = 10 ;Left most point of region to check
Local $top_Region = 10 ;Top most point of region to check
Local $right_Region = 100 ;Right most point of region to check
Local $bottom_Region = 100 ;Bottom most point of region to check
Local $far_left_point = $right_Region+1 ;This is necessary for error checking
Local $bottom_point = $bottom_point+1 ;This is necessary for error checking
For $y = $top_Region To $bottom_Region
    For $x = $left_Region To $right_Region
        If PixelGetColor($x,$y)=0 Then
            If $x<$far_left_point Then
                $far_left_point=$x
                $bottom_point=$y
            EndIf
        EndIf
    Next
Next
If $far_left_point>$right_Region or $bottom_point>$bottom_Region Then 
    MsgBox(0,"Error","Black was not found in this Region")
Else
    MouseMove($far_left_point,$bottom_point)
    MsgBox(0,"Far Left Point","Far Left Point coord: " & $far_left_point & "," & $bottom_point)
EndIf

Thanks, I'm not able to make your example work, but I really aprecciatte your help. Anyways it always returns me "Black was not found in this Region" and it slows down compared to my pixelsearch example.

I was thinking on make like 3 or 4 pixelsearch on diference top to bottom position like:

$coord = PixelSearch($size[0], $size[1], $size[0]+$size[2], $size[1]+$size[3], 0x000000, 30)
$coord2 = PixelSearch($size[0], $size[1], $size[0]+$size[2], ($size[1]+$size[3]) /2, 0x000000, 30)
$coord3 = PixelSearch($size[0], $size[1], $size[0]+$size[2], ($size[1]+$size[3])/4, 0x000000, 30)
... etc...

and somehow tell the program to determinate the $coordx[0] with the lowest value (so it must be the one most to the left... not pretty sure about if my theory is right)

Will try later.

Thanks for helping

Edited by adolfito121

Share this post


Link to post
Share on other sites

Adolfito121,

Did you change the variables for $left_Region, $top_Region, $right_Region, $bottom_Region. as you will see those variables will declare the region that you are searching in. You can use 'AutoIt Window Info' Tool to find the pixel coords to use, first find the top/left corner of the region you wish to use, the first coord will be $left_Region, the second coord will be your $top_Region. Then use the tool again to and location the bottom/right corner of the region you wish to search. The first coord will be your $right_Region, and the second coord will be your $bottom_Region. I originally testing witht he pick you provided in your post and was given a positive result, the coords I provided are an example only, and not what I used to get a positive result from the pic you provided in the post. My example is also set for searching your entire screen, if you are providing coords for just the window you are working with you will need to add Opt('PixelCoordMode', 2), which is 'relative coords to the client area of the defined window', to the top of the script. My example by default works under Opt('PixelCoordMode', 1) which is 'absolute screen coordinates (default)'.

As for speed, My test on the pic you provided, yielded a result in about 1 second. Maybe you should provide your version of my example, so we may see whats going wrong.

If you have done all this correctly, and still not receiving a positive result, then maybe it has something to do with the window in which your trying to find the pixel. Some windows will appear invisible to Pixel functions such as Flash and some Javascript windows. In which you will have to find another solution.

Realm


My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

here is a little example based on your picture posted here, I just had it open in windows photo viewer to test, different system enviroments mean this may not work for you as is, but will give you an idea and option.

It will also be slow as I just used mt whole desktop as the starting search area, you can easily modify that.

$checksum = 1864762705 ; this is the checksum of an area around the pixel you want

$y = 0 ; starting y co-ordinate

Do ; loop the code
    $asearch = PixelSearch(0,$y,@DesktopWidth,@DesktopHeight,0x000000) ; search for a black pixel
    If IsArray($asearch) Then ; if we find one, check the area around it for our given checksum
        $check = PixelChecksum($asearch[0]-1,$asearch[1]-1,$asearch[0]+1,$asearch[1]+1)
    EndIf
    $y += 1 ; increase the y coordinate of the searcg area
Until $check = $checksum Or $y > @DesktopHeight; we found our checksum or we did not.

MouseMove($asearch[0],$asearch[1]) ; move mouse to coord to chech we are correct
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hi,

if you know the area to search (i think within the red borders), you have to search through the columns with a width of 1 Pixel.

If you search through thall columns from left to right, the first black pixel you will get is the one you are looking for...

Opt("PixelCoordmode", 2)
Opt("MouseCoordmode", 2)


$hgui = GUICreate("")
$pic = GUICtrlCreatePic("findblackleft.bmp", 1, 1, 300, 200) ;png needs more lines...
GUISetState()
Sleep(100)
$t = TimerInit()
For $x = 1 To 200                            ;width of the area
    $a = PixelSearch($x, 1, $x, 200, 0x000000) ;pixelsearch only in the column
    If IsArray($a) Then                      ;if a black pixel is found.....
        $t = TimerDiff($t)
        MouseMove($a[0], $a[1], 0)           ;show it with the mousecursor
        MsgBox(0, "Found black Pixel in " & Int($t * 1000) / 1000 & " ms at", $a[0] & "  " & $a[1]) ;coordinates
        Exit
    EndIf
Next
msgbox(0,"Pixel not found...","")
really fast, <20ms @2.5Ghz Edited by AndyG

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks to you all for rapid response.

The case is that I'm doing the pixelsearch on a video (the source is a webcam) and the image that I've posted was just to explain my problem a little better (due my bad english).

I've a main gui, with a little webcam child window

webcam.udf

The main gui

$Main = GUICreate("TEST", @DesktopWidth, @DesktopHeight)

and the webcam childwindow:

$cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD, $WS_VISIBLE), "int", 5, "int", 10, "int", 480, "int", 320, "hwnd", $Main, "int", 1)

DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DLG_VIDEOSOURCE, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DLG_VIDEOFORMAT, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)

I've also made a transparent gui, that can be resized and moved, to set the searching area of pixelsearch:

$Guipeque = GUICreate("minigui", $variable1, $variable2, $variable3, $variable4, $WS_POPUPWINDOW, $WS_EX_LAYERED + $GUI_WS_EX_PARENTDRAG, WinGetHandle(AutoItWinGetTitle()))
WinSetOnTop($Guipeque, "minigui", 1)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($Guipeque, 0xABCDEF, 255)
(I would love to make the borders bigger, but that's another issue).

I resize and move this little gui with some buttons:

Case $msg = $Button3
            $XX = $XX + 3
            WinMove("minigui", "", $variable1 + $XX, $variable2 + $YY, $variable3 + $XXX, $variable4 + $YYY)

And finally I've a button that says to the script that looks for the grey most left pixel inside the transparent gui:

Case $msg = $Button9
            GUICTRLREAD($input3);this is a input that lets us change the shade-variation at the moment
            $size = WinGetPos("minigui")
            $mitad = $size[3]/2 ;I use this to force the pixelsearch at least to look on the middle of the little trasnparent gui (for my pourpose is better than the top-left pixel)
            Sleep(10)
            $coord1 = PixelSearch($size[0],$size[1]+$mitad, $size[0] + $size[2], $size[1]+$mitad , 0x222222, $algoritmo *3)
            If Not @error Then
                MouseMove($coord1[0], $coord1[1])
            Else
                MsgBox(48, "ERROR", "CAN'T FIND GREY PIXEL", 10)
            EndIf

Please notice that now I'm looking for a grey pixel (in final version maybe I'll do a radio button that lets the user choose beetwen search for grey or for black pixels.

I'm going to try AndyG (I like the column idea of searching) and JohnOne (not sure about I've understood the checksum idea, but sounds perfect for learning) examples and I will report later if they work fine on that ultra-slooooooowly computer.

I also want to thank Realm, I've tried your example but I didn't get it to work (super-newbie strikes back)

Anyway I want to thank you all your help, not just on that topic, I'm learning a lot.

Greets from Barcelona

Edited by adolfito121

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Hmmm, Im not convinced this sort of appoach will work very well, if at all, with a video source on acount of noise.

There have been some discussions on video and motion detection but I dont think any reliable outcome was achieved, and dont know where the threads are.

Best of luck.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

with a video source on acount of noise.

yes, because of the noise it could be necessary to search with "shade-variation". And unfortunately this could be the reason for inaccurate results.

To verify a found pixel at (x;y), it would be clever to check the colours of some Pixels in the neigbourhood.

i.E: if pixelcolor(x-5,y)<>grey and pixelcolor(x+5,y)=grey and pixelcolor(x,y-5)<>grey.....and so on...which depends on the speed of the detection

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

yes, because of the noise it could be necessary to search with "shade-variation". And unfortunately this could be the reason for inaccurate results.

To verify a found pixel at (x;y), it would be clever to check the colours of some Pixels in the neigbourhood.

i.E: if pixelcolor(x-5,y)<>grey and pixelcolor(x+5,y)=grey and pixelcolor(x,y-5)<>grey.....and so on...which depends on the speed of the detection

The case is that during my testing I point the camera to the monitor and it reads almost the same pixel (the cursor doens't move so much even pressing the button that makes the pixel search with a hotkey press) and this case is even worst than the real working scenario (two colours, the camera at 12 inches from the object to be measured, and with a light rear the object).

I've been googling and now I understand the JohnOne's checksum idea, it seems that it would be very accuratted for static images.

This is my testing envoirement:

Posted Image

Edited by adolfito121

Share this post


Link to post
Share on other sites

It would helped me a lot (to help you a bit ;))  if you could post a Screenshot of the area where you are searching the grey pixel. I mean a screenshot of the content of the transparent window with the "real working scenario (two colours, the camera at 12 inches from the object to be measured, and with a light rear the object)."

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

It would helped me a lot (to help you a bit ;))  if you could post a Screenshot of the area where you are searching the grey pixel. I mean a screenshot of the content of the transparent window with the "real working scenario (two colours, the camera at 12 inches from the object to be measured, and with a light rear the object)."

Well, I first need the script to read before mounting a computer near a spring coiling machine (this is going to be a cheap spring measuring system), something like:

Posted Image

I work on a tiny spring company and we can't afford on a measuring system, so I want to use a computer with a webcam (there are somes at 720i resolution) to measure a spring.

The real working conditions may be something like this:

Posted Image

(ovbiously with a lot of noise on the image.

I can solve the issue of Pixelsearch pointing at the left-top pixel just doing the searching area not as tall as drawed above.

Most of the times sprins will look like the image posted, but they're not always perpendicular like the image.

Edited by adolfito121

Share this post


Link to post
Share on other sites

Hi,

25 jears ago i studied mechanical engeneering^^. At this time i worked in a company to build a machine to unravel a big ball of springs :) 

But btt, i would recommend to convert the picture of the spring to a "grayscale" picture via a Sobel-Operator (there are other methods of edge-detection) to reduce the noise and detect the edges. This could be easily done by a simple matrix-multiplication. 

Because the beginning and the end of the spring in the picture is in a certain area, it is only necessary to transform those two parts of the picture. 

But if the spring is not aligned exact horizontally, dont worry. Then you have to detect the 4 "corners" of the spring to measure the length and the diameter. Can you make a "noisy" picture with your webcam and post it here? (or pm me if you like) please dont compress the picture!

Then it is easy to write a "fast" spring-picture-edge-detection-and-length/diameter-measuring-script ;)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Hi,

25 jears ago i studied mechanical engeneering^^. At this time i worked in a company to build a machine to unravel a big ball of springs :) 

But btt, i would recommend to convert the picture of the spring to a "grayscale" picture via a Sobel-Operator (there are other methods of edge-detection) to reduce the noise and detect the edges. This could be easily done by a simple matrix-multiplication. 

Because the beginning and the end of the spring in the picture is in a certain area, it is only necessary to transform those two parts of the picture. 

But if the spring is not aligned exact horizontally, dont worry. Then you have to detect the 4 "corners" of the spring to measure the length and the diameter. Can you make a "noisy" picture with your webcam and post it here? (or pm me if you like) please dont compress the picture!

Then it is easy to write a "fast" spring-picture-edge-detection-and-length/diameter-measuring-script ;)

The world is a tissue, isn't it? :shocked: I will take the camera to my workplace next week(I haven't any laptop avaible until monday)

I was thinkin on a light behind the spring to get the white background.

Mechanical engeneering... I left unfinished the High School due some family problems... maybe is why Sobel Operator doesn't seems "easily done by a simple matrix-multiplication" to me ;)

Never thought about the possibilty of read the diameter of the springs, it would be great, of course, but as a proof of concept I will start just with the lenght... and who knows.

About the unravel machine... I don't found them on youtube at the moment, but sometime ago I saw videos of a little machine where someone put a "ball" of springs and it unraveled it in just few seconds... Is this what you're working at?

Sound very interesting.

What I don't know if I have explained well is that I want this program to work while the machine is coiling the springs, so it can detect large or short springs, can I apply the sobel operator on a moving video?¿?

Edited by adolfito121

Share this post


Link to post
Share on other sites

Hi,

i wrote some lines in assembler to detect the edges in a picture. But now i think in your case it is much easier to store the picture of the spring in a 1 Bit per Pixel format, aka black&white. So the only thing you have to do is to make a screenshot of the "spring-video". There is a function in the UDF called _WebcamSnap(). This Function creates a Bitmap, very nice...

And then the only thing to do is to detect the 4 corners. Pixelsearch ist fast enough i think...something like this:

Opt("PixelCoordmode", 2)
Opt("MouseCoordmode", 2)

Dim $p[4][2]                               ; x+y coordinates of the points

$hgui = GUICreate("")
$pic = GUICtrlCreatePic("springbw-10degree.bmp", 1, 1, 330, 150) ;png needs more lines...
GUISetState()
Sleep(100)
$t = TimerInit()
For $x = 1 To 400                          ;width of the area
    $a = PixelSearch($x, 1, $x, 400, 0x000000) ;pixelsearch only in the column
    If IsArray($a) Then                    ;if a black pixel is found.....
        MouseMove($a[0], $a[1], 0)         ;show it with the mousecursor
        ;      MsgBox(0, "Found black Pixel in " & Int($t * 1000) / 1000 & " ms at", $a[0] & "  " & $a[1]) ;coordinates
        $p[0][0] = $a[0]                   ;x
        $p[0][1] = $a[1]                   ;y
        ExitLoop
    EndIf
Next

For $x = 400 To 1 Step -1                  ;width of the area
    $a = PixelSearch($x, 1, $x, 400, 0x000000) ;pixelsearch only in the column
    If IsArray($a) Then                    ;if a black pixel is found.....
        MouseMove($a[0], $a[1], 0)         ;show it with the mousecursor
        ;      MsgBox(0, "Found black Pixel in " & Int($t * 1000) / 1000 & " ms at", $a[0] & "  " & $a[1]) ;coordinates
        $p[1][0] = $a[0]                   ;x
        $p[1][1] = $a[1]                   ;y
        ExitLoop
    EndIf
Next

;oben
$a = PixelSearch(1, 1, 400, 400, 0x000000)
If IsArray($a) Then                        ;if a black pixel is found.....
    MouseMove($a[0], $a[1], 0)             ;show it with the mousecursor
    ;       MsgBox(0, "Found black Pixel in " & Int($t * 1000) / 1000 & " ms at", $a[0] & "  " & $a[1]) ;coordinates
    $p[2][0] = $a[0]                       ;x
    $p[2][1] = $a[1]                       ;y
EndIf

$a = PixelSearch(400, 400, 1, 1, 0x000000)
If IsArray($a) Then                        ;if a black pixel is found.....
    MouseMove($a[0], $a[1], 0)             ;show it with the mousecursor
 ;         MsgBox(0, "Found black Pixel in " & Int($t * 1000) / 1000 & " ms at", $a[0] & "  " & $a[1]) ;coordinates
    $p[3][0] = $a[0]                       ;x
    $p[3][1] = $a[1]                       ;y
EndIf

$t = TimerDiff($t)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $t = ' & $t & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

;length1=sqrt(deltay^2+deltax^2)  ;P0 and P1
$lenght1 = sqrt(($p[1][1] - $p[0][1])^2+($p[1][0] - $p[0][0])^2)
MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @LF & '$lenght' & @LF & @LF & 'Return:' & @LF & $lenght1) ;### Debug MSGBOX
;length2=sqrt(deltay^2+deltax^2)  ;P2 and P3
$lenght2 = sqrt(($p[3][1] - $p[2][1])^2+($p[3][0] - $p[2][0])^2)
MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @LF & '$lenght' & @LF & @LF & 'Return:' & @LF & $lenght2) ;### Debug MSGBOX

;height
$height1 = sqrt(($p[3][1] - $p[0][1])^2+($p[3][0] - $p[0][0])^2)
MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @LF & '$height' & @LF & @LF & 'Return:' & @LF & $height1) ;### Debug MSGBOX
$height2= sqrt(($p[2][1] - $p[1][1])^2+($p[2][0] - $p[1][0])^2)
MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @LF & '$height' & @LF & @LF & 'Return:' & @LF & $height2) ;### Debug MSGBOX

springbw-10degree.bmp

I don´t know how many springs you want to measure in one second, but it should be possible to measure the lenght and diameter of 5 to 10 springs in a second.

Share this post


Link to post
Share on other sites

:) This is very fast.

The question is if the camera will give me enough speed doing the _WebcamSnap(), saving it and autoit reading it.

Pixelsearch is fast enough for me, but there's no doubt that your script is far accurate for quality measuring.

Until monday I can't put the camera next to a working machine (I'll take my wife´s laptop to te job ;) ) so I will take snapshot of some springs and maybe a video to make probes at home.

Did you notice that your script, combined with a mechanical element (the simplest, a cd drive and the comand CDTray(D, "open")) gives you a cheap spring selector? Just take a white surface, a feeder system to put springs over the white surface and a webcam... perfect for thoses times that you hve to select manually springs ;)

Once again, I'm not sure if I will arrive at the goal with this idea, but thaks for your time and for the lot that I'm learning.

Greets from Barcelona

Share this post


Link to post
Share on other sites

The question is if the camera will give me enough speed doing the _WebcamSnap(), saving it and autoit reading it.

sry, i have no webcam, i use my digital cam as a "webcam" sometimes. So i can not examine, if a "screenshot" of the video is possible or not. If a screenshot of the video is possible, then there is no need to save a bitmap into a file! Copy the frame of the Video into memory and search there for the corners is surely faster. 

Share this post


Link to post
Share on other sites

sry, i have no webcam, i use my digital cam as a "webcam" sometimes. So i can not examine, if a "screenshot" of the video is possible or not. If a screenshot of the video is possible, then there is no need to save a bitmap into a file! Copy the frame of the Video into memory and search there for the corners is surely faster. 

Time ago I asked about the possibility of saving a snap into memory and not on hdd in this topic:

topic

but nobody point me in the right direction.

This weekend I will try how long it takes doing a snapshot and saving on the hdd.

Thanks again.

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Got a real image of a spring next to the camera using the snapshot control of webcam udf (not yet on the coiling machine ;) , but looks similar)

Posted Image

(imagehack converted it to png instead)

Snapshot doen't shows the searching area rectangle (a transparent gui)

I'm still using a low-res camerra because I've a 720p one but it hasn't a manual focus, and the eyetoy lets me focus manually objects that are very close without bluring the image (will look for a high-res camera with manual focus).

I also only get a 640*480 image with the high-res camera due to Vidcap32.dd only lets me choose that resolution as the best avaible.

Now I'm going to try to adapt AndyG code to, at least, measure the lenght of the spring. The case is that I will never haver the entire spring on screen, so I'have to record one spring lenght as the "real good" and the next are going to be X mm shorter or longer than the real-good spring.

Will post results. Thanks again for helping

Edited by adolfito121

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0