Hi
I am using RR in a slightly diferent way to most by reading the forum. I am using it for machine vision, to try and read a 7 segment display and send the value ot a text file. I have had the display reader VBS code running, but now when I try to start it, I get a type mismatch error for the arrays starting on line 9. Code is listed below. I haven't changed anything and it just stopped working.
A rough explanation of the code is: Each of the 7 segments in on the screen is checked for colour by a single pixel whose location is defined by the arrays at the top of the code. The code then does a comparison for lit segments and sets a variable with the decimal value.
Dim Pixels
Dim SegVal
Dim SegLit
Dim SegArray
Dim SegBin
Dim SegDec
SegArray(1,1) =136
SegArray(1,2) =102
SegArray(2,1) =123
SegArray(2,2) =94
SegArray(3,1) =148
SegArray(3,2) =95
SegArray(4,1) =136
SegArray(4,2) =87
SegArray(5,1) =123
SegArray(5,2) =80
SegArray(6,1) =148
SegArray(6,2) =80
SegArray(7,1) =136
SegArray(7,2) =72
pixels = GetPixels()
for i = 1 to 7
pxl = ((SegArray(i,2) * 320) + SegArray(i,1)) * 3
SegVal(i) = Pixels(pxl) + Pixels(pxl+1) + Pixels(pxl+2)
if SegVal(i) > 50 Then
SegLit(i) = 1
Else
SegLit(i) = 0
End If
next
SegBin = SegLit(7) + (2 * SegLit(6)) + (4 * SegLit(5)) + (8 * SegLit(4)) + (16 * SegLit(3)) + (32 * SegLit(2)) + (64 * SegLit(1))
SetVariable "Seg1", SegLit(1)
SetVariable "Seg2", SegLit(2)
SetVariable "Seg3", SegLit(3)
SetVariable "Seg4", SegLit(4)
SetVariable "Seg5", SegLit(5)
SetVariable "Seg6", SegLit(6)
SetVariable "Seg7", SegLit(7)
Select Case SegBin
Case 18
SegDec = 1
Case 58
SegDec = 4
Case 82
SegDec = 7
Case 91
SegDec = 3
Case 93
SegDec = 2
Case 107
SegDec = 5
Case 111
SegDec = 6
Case 119
SegDec = 0
Case 122
SegDec = 9
Case 127
SegDec = 8
Case Else
SegDec = -1
End Select
SetVariable "DecOut", SegDec
|
|