Jump to content

ScanTron


Recommended Posts

Hey guys,

Do you remember the Scan-Tron forms from testing in school?  I'm hoping to stream-line the process of entering "downtime" (I work on a production line) into our database.  We try to maintain a database for reoccurring issues in order to help with preventative maintenance planning.  

Our current program has some issues, and the programmer washed his hands of it.  I have written several other programs for my co-workers (thanks Auto-It) and they have requested that I consider writing a replacement.

The program itself would be quite simple; however, I would like to improve the process by supplying technicians with a Scan-Tron type of form that can be scanned, allowing the program to automatically insert data into the database.

I have researched the help file extensively, as well as the forums, but can't seem to find what I'm looking for.  Once the sheet is scanned, I need to analyze the image by reading the percentage of dark pixels within a set of rectangles, in order to find the one that has been filled in.  Any suggestions on which function would help me complete this task would be much appreciated.

How neat would it be to create your own Scan-Tron sheets!

Thanks guys!

Edited by NitNG4le
If $uHappy = True And $uKnow_it = True Then

      For $i = 1 To 2 Step 1

              Clap()
      Next

EndIf

 

Link to comment
Share on other sites

This is almost certainly a job for a custom UDF, it's doubtful there will be anything out of the box.

It will depend on position and orientation of image as well as the quality.

I imagine this is a rare need for pixelgetcolor function and perhaps some gdi voodoo to create black and white from greyscale.

Edited by JohnOne

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

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Sounds like a tall order for Autoit to do something like that :)

I assume you would need some kind of machine to scan those that has an API you can interface, but I also assume you want to go straight from just a PC scanner into AutoIT?

 

I would think that since your trying to do Digital work, that your project would be much easier if your input was Digital.  So instead of giving out Analog scan cards, have people fill in a Electronic form, or a Spreadsheet or something.

 

Now as far as "image" functions all I can think of is ImageSearch and PixelSearch and both of those do not really sound suited for your needs. 

Even if you hardcoded search parameters, you would have to make sure every scan has the excact same alignment and I just do not know how accurate that would be.

You could use an AutoIT GUI to simulate an electronic Scan-Tron card and when people hit "send" it sends its digital data to the database or to a staging area for your review before you submit it to the database, you could even include a screenshot feature and some logging so you can visually see what the electronic card looked like and who submitted it/when.

Even if you did not use AutoIT to send the GUI data directly at least using a screenshot ensure a 100% perfect image each time of the same format so you can then use some kind of scan algorithm to ensure accuracy.

 

I am just a novice but came up with this example as a proof of concept.  You can change this to do what you need so instead of saving to the script dir it may go to a network share location, the file name may contain the user, computer name, or time it was submitted.

Instead of filewrite you may use a log file or even better the .ini UDF so that you can then easily parse and import these into another autoit script.

And we have our image incase you really did want to "scan" these.

#include <ScreenCapture.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#Region ### START Koda GUI section ### Form=C:\Users\it022565\Desktop\Scantron\scantron.kxf
$Form1 = GUICreate("Electronic Scantron", 247, 438, 192, 124)
$Label1 = GUICtrlCreateLabel("SCANTRON", 108, 8, 64, 17)
$Label2 = GUICtrlCreateLabel("1", 40, 48, 10, 17)
$Label3 = GUICtrlCreateLabel("2", 40, 136, 10, 17)
$Label4 = GUICtrlCreateLabel("3", 40, 216, 10, 17)
$Label5 = GUICtrlCreateLabel("4", 48, 288, 10, 17)
GUIStartGroup()
$Radio1 = GUICtrlCreateRadio("A", 64, 48, 113, 17)
$Radio2 = GUICtrlCreateRadio("B", 64, 64, 113, 17)
$Radio3 = GUICtrlCreateRadio("C", 64, 80, 113, 17)
$Radio4 = GUICtrlCreateRadio("D", 64, 96, 113, 17)
GUIStartGroup()
$Radio5 = GUICtrlCreateRadio("A", 62, 136, 113, 17)
$Radio6 = GUICtrlCreateRadio("B", 62, 152, 113, 17)
$Radio7 = GUICtrlCreateRadio("C", 62, 168, 113, 17)
$Radio8 = GUICtrlCreateRadio("D", 62, 184, 113, 17)
GUIStartGroup()
$Radio9 = GUICtrlCreateRadio("A", 64, 216, 113, 17)
$Radio10 = GUICtrlCreateRadio("B", 64, 232, 113, 17)
$Radio11 = GUICtrlCreateRadio("C", 64, 248, 113, 17)
$Radio12 = GUICtrlCreateRadio("D", 64, 264, 113, 17)
GUIStartGroup()
$Radio13 = GUICtrlCreateRadio("A", 66, 289, 113, 17)
$Radio14 = GUICtrlCreateRadio("B", 66, 305, 113, 17)
$Radio15 = GUICtrlCreateRadio("C", 66, 321, 113, 17)
$Radio16 = GUICtrlCreateRadio("D", 66, 337, 113, 17)
$Button1 = GUICtrlCreateButton("Submit", 140, 376)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUISetStyle($WS_POPUP, -1, $Form1)
            _ScreenCapture_CaptureWnd(@ScriptDir & "\ElectronicScantron.jpg", $Form1)
            GUISetStyle($GUI_SS_DEFAULT_GUI, -1, $Form1)
            _FileCreate(@ScriptDir & "\results.txt")
            FileWrite(@ScriptDir & "\results.txt", CheckRadio1() & @CRLF & CheckRadio2() & @CRLF & CheckRadio3() & @CRLF & CheckRadio4())
            If MsgBox(4, "", "Submit Completed - Results Saved" & @CRLF & "Exit Now?") = 6 Then Exit


    EndSwitch
WEnd

Func CheckRadio1()
    If GUICtrlRead($Radio1) = $GUI_CHECKED Then Return "1) A"
    If GUICtrlRead($Radio2) = $GUI_CHECKED Then Return "1) B"
    If GUICtrlRead($Radio3) = $GUI_CHECKED Then Return "1) C"
    If GUICtrlRead($Radio4) = $GUI_CHECKED Then Return "1) D"
EndFunc

Func CheckRadio2()
    If GUICtrlRead($Radio5) = $GUI_CHECKED Then Return "2) A"
    If GUICtrlRead($Radio6) = $GUI_CHECKED Then Return "2) B"
    If GUICtrlRead($Radio7) = $GUI_CHECKED Then Return "2) C"
    If GUICtrlRead($Radio8) = $GUI_CHECKED Then Return "2) D"
EndFunc

Func CheckRadio3()
    If GUICtrlRead($Radio9) = $GUI_CHECKED Then Return "3) A"
    If GUICtrlRead($Radio10) = $GUI_CHECKED Then Return "3) B"
    If GUICtrlRead($Radio11) = $GUI_CHECKED Then Return "3) C"
    If GUICtrlRead($Radio12) = $GUI_CHECKED Then Return "3) D"
EndFunc

Func CheckRadio4()
    If GUICtrlRead($Radio13) = $GUI_CHECKED Then Return "4) A"
    If GUICtrlRead($Radio14) = $GUI_CHECKED Then Return "4) B"
    If GUICtrlRead($Radio15) = $GUI_CHECKED Then Return "4) C"
    If GUICtrlRead($Radio16) = $GUI_CHECKED Then Return "4) D"
EndFunc

 

Edited by ViciousXUSMC
Link to comment
Share on other sites

First of all, thanks guys for your time and input.

I did play around with PixelSearch a bit.  Of course it wanted to return the coordinates of the first pixel it found based on my criteria (I created a simulated "filled in circle" and an "empty circle" with Greenfish using a variety of shades of black).  I tried a "For, Next" statement; basically, once it found a pixel with an acceptable shade of black, it counted +1, then continued the PixelSearch from there.  I ended up with the number of accepted pixels within the rectangle.  I was able to put that number against the total number of pixels and end up with a nice, easy percentage.

I thought perhaps I would be able to tune this number, based on the amount of allowance I specified in the function, for a certain amount of error when analyzing the image, but I can't foresee this method ever becoming practical; less likely reliable.

I may continue to experiment with the idea; however, I will stick to what I know for the time being, and create a pretty GUI with a simple SQLite database, and go from there.

Thanks guys!

If $uHappy = True And $uKnow_it = True Then

      For $i = 1 To 2 Step 1

              Clap()
      Next

EndIf

 

Link to comment
Share on other sites

Don't worry JohnOne.....I'm far from quitting on the idea.  I'll keep it on the back burner while I organize/structure the database.  I'm going to continue with the GUI creation for the technicians that prefer the manual form of entry.  I guess I'm trying to provide them with options.

I came up with another possible solution.  I have written spreadsheet type programs with "In-Sight Explorer" to analyze images taken by our Cognex network-based cameras.  We often use them to find and measure features on parts.  I have a few extra cameras lying around.  I could actually build a "station" where the scan-tron forms could be set under the camera.  Finding the "filled-in" circles would be an easy job for the program, simply by placing a small "X" or dot or whatever in one corner of the sheet for the program to reference from.

Once I have some nice code down, and a few sample images, I will be glad to post them.  I, too, believe the project is possible; and thanks for your support!

If $uHappy = True And $uKnow_it = True Then

      For $i = 1 To 2 Step 1

              Clap()
      Next

EndIf

 

Link to comment
Share on other sites

Glad to hear it.

I like your attitude.

I was going to say don't build a feeding trough until you have food to put in it.

But while you're building that trough, you'll be learning how to get food.

Best of luck, and keep posting.

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

Monkey's are, like, natures humans.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...