fix mirroring
This commit is contained in:
parent
fdab3a9d81
commit
ae6365d4cc
|
@ -12,9 +12,11 @@ parser.add_argument('-o', '--output') # option that takes a value
|
|||
parser.add_argument('-f', '--format', choices=['firmware','nodered','nodered_int'], default='firmware', help='Output format') # option that takes a value
|
||||
parser.add_argument('-v', '--verbose', action='store_true') # on/off flag
|
||||
parser.add_argument('-i', '--invert', action='store_true')
|
||||
parser.add_argument('-y', '--ymirror', action='store_true')
|
||||
parser.add_argument('-x', '--xmirror', action='store_true')
|
||||
|
||||
args = parser.parse_args()
|
||||
print(args.filename, args.output, args.format,args.verbose,args.invert)
|
||||
print(args.filename, args.output, args.format,args.verbose,args.invert,args.xmirror,args.ymirror)
|
||||
|
||||
outputfilename="result.txt"
|
||||
if args.output is not None:
|
||||
|
@ -60,6 +62,8 @@ elif args.format=='nodered_int': #Nodered Int
|
|||
|
||||
|
||||
|
||||
xrange = range(im.size[0])
|
||||
yrange = range(im.size[1])
|
||||
|
||||
|
||||
def calculateDistance(x1,y1,x2,y2):
|
||||
|
@ -68,22 +72,35 @@ def calculateDistance(x1,y1,x2,y2):
|
|||
|
||||
with open(outputfilename, 'w') as f:
|
||||
f.write(output_pre)
|
||||
for x in range(im.size[0]):
|
||||
_xrange=xrange
|
||||
if args.xmirror:
|
||||
_xrange=reversed(xrange)
|
||||
for ix,x in enumerate(_xrange):
|
||||
if args.verbose:
|
||||
print("ix="+str(ix)+" x="+str(x))
|
||||
f.write(output_col_preL)
|
||||
if output_col_writeCol_flag:
|
||||
f.write(str(x))
|
||||
f.write(output_col_preR)
|
||||
|
||||
columnValue=0
|
||||
for y in reversed(range(im.size[1])):
|
||||
|
||||
_yrange=yrange
|
||||
if args.ymirror:
|
||||
_yrange=reversed(yrange)
|
||||
for iy,y in enumerate(_yrange):
|
||||
if args.verbose:
|
||||
print("iy="+str(iy)+" y="+str(y))
|
||||
c = pix[x,y] #get pixel
|
||||
if args.verbose:
|
||||
print("get pixel "+str(x)+","+str(y)+": color="+str(c))
|
||||
if args.invert:
|
||||
c=255-c
|
||||
|
||||
if (c[0]>127):
|
||||
if output_col_write_binary_flag:
|
||||
f.write("1")
|
||||
columnValue+=pow(2,y)
|
||||
columnValue+=pow(2,iy)
|
||||
else:
|
||||
if output_col_write_binary_flag:
|
||||
f.write("0")
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
msg.payload="\
|
||||
0000111111111000\
|
||||
0001000000000100\
|
||||
0010001111100010\
|
||||
0010010000010010\
|
||||
0010010000010010\
|
||||
0010010000010010\
|
||||
0010001111100010\
|
||||
0001000000000100\
|
||||
0000111111111000\
|
||||
";
|
||||
return msg;
|
|
@ -0,0 +1,12 @@
|
|||
msg.payload="\
|
||||
0000000000000000\
|
||||
0000111000001110\
|
||||
0001001000001010\
|
||||
0010011111111010\
|
||||
0010000000000010\
|
||||
0011111111111010\
|
||||
0000000000001010\
|
||||
0000000000001110\
|
||||
0000000000000000\
|
||||
";
|
||||
return msg;
|
|
@ -0,0 +1,12 @@
|
|||
msg.payload="\
|
||||
0000111000011110\
|
||||
0001001000100010\
|
||||
0010011001000010\
|
||||
0010100010000010\
|
||||
0010111100011010\
|
||||
0010000000101010\
|
||||
0010000001001010\
|
||||
0001111110001110\
|
||||
0000000000000000\
|
||||
";
|
||||
return msg;
|
|
@ -0,0 +1,12 @@
|
|||
msg.payload="\
|
||||
0000111000111000\
|
||||
0001001000100100\
|
||||
0010001000100010\
|
||||
0010011010110010\
|
||||
0010100101001010\
|
||||
0010011000110010\
|
||||
0010000010000010\
|
||||
0001000101000100\
|
||||
0000111000111000\
|
||||
";
|
||||
return msg;
|
|
@ -0,0 +1,12 @@
|
|||
msg.payload="\
|
||||
0011111111100000\
|
||||
0010000000100000\
|
||||
0011111110100000\
|
||||
0000000010100000\
|
||||
0000011110111110\
|
||||
0000010000000010\
|
||||
0000011110111110\
|
||||
0000000010100000\
|
||||
0000000011100000\
|
||||
";
|
||||
return msg;
|
|
@ -0,0 +1,12 @@
|
|||
msg.payload="\
|
||||
0011111100111000\
|
||||
0010000100100100\
|
||||
0010000100100010\
|
||||
0010110100110010\
|
||||
0010110010001010\
|
||||
0010101001110010\
|
||||
0010101000000010\
|
||||
0010101000000100\
|
||||
0011100111111000\
|
||||
";
|
||||
return msg;
|
|
@ -0,0 +1,12 @@
|
|||
msg.payload="\
|
||||
0000111111111000\
|
||||
0001000000000100\
|
||||
0010000000000010\
|
||||
0010011101111010\
|
||||
0010100101001010\
|
||||
0010100101001010\
|
||||
0010010100110010\
|
||||
0001010100000100\
|
||||
0000110011111000\
|
||||
";
|
||||
return msg;
|
|
@ -0,0 +1,12 @@
|
|||
msg.payload="\
|
||||
0011100000000000\
|
||||
0010100000000000\
|
||||
0010100011111110\
|
||||
0010100100000010\
|
||||
0010101000111110\
|
||||
0010110001000000\
|
||||
0010000010000000\
|
||||
0010000100000000\
|
||||
0011111000000000\
|
||||
";
|
||||
return msg;
|
|
@ -0,0 +1,12 @@
|
|||
msg.payload="\
|
||||
0000111000111000\
|
||||
0001000101000100\
|
||||
0010010010010010\
|
||||
0010101000101010\
|
||||
0010101000101010\
|
||||
0010101000101010\
|
||||
0010010010010010\
|
||||
0001000101000100\
|
||||
0000111000111000\
|
||||
";
|
||||
return msg;
|
|
@ -0,0 +1,12 @@
|
|||
msg.payload="\
|
||||
0000111110011000\
|
||||
0001000001010100\
|
||||
0010011001010010\
|
||||
0010100101001010\
|
||||
0010100101001010\
|
||||
0010111101110010\
|
||||
0010000000000010\
|
||||
0001000000000100\
|
||||
0000111111111000\
|
||||
";
|
||||
return msg;
|
|
@ -1,12 +0,0 @@
|
|||
msg.payload="\
|
||||
0001111111110000\
|
||||
0010000000001000\
|
||||
0100011111000100\
|
||||
0100100000100100\
|
||||
0100100000100100\
|
||||
0100100000100100\
|
||||
0100011111000100\
|
||||
0010000000001000\
|
||||
0001111111110000\
|
||||
";
|
||||
return msg;
|
|
@ -1,12 +0,0 @@
|
|||
msg.payload="\
|
||||
0000000000000000\
|
||||
0111000001110000\
|
||||
0101000001001000\
|
||||
0101111111100100\
|
||||
0100000000000100\
|
||||
0101111111111100\
|
||||
0101000000000000\
|
||||
0111000000000000\
|
||||
0000000000000000\
|
||||
";
|
||||
return msg;
|
|
@ -1,12 +0,0 @@
|
|||
msg.payload="\
|
||||
0111100001110000\
|
||||
0100010001001000\
|
||||
0100001001100100\
|
||||
0100000100010100\
|
||||
0101100011110100\
|
||||
0101010000000100\
|
||||
0101001000000100\
|
||||
0111000111111000\
|
||||
0000000000000000\
|
||||
";
|
||||
return msg;
|
|
@ -1,12 +0,0 @@
|
|||
msg.payload="\
|
||||
0001110001110000\
|
||||
0010010001001000\
|
||||
0100010001000100\
|
||||
0100110101100100\
|
||||
0101001010010100\
|
||||
0100110001100100\
|
||||
0100000100000100\
|
||||
0010001010001000\
|
||||
0001110001110000\
|
||||
";
|
||||
return msg;
|
|
@ -1,12 +0,0 @@
|
|||
msg.payload="\
|
||||
0000011111111100\
|
||||
0000010000000100\
|
||||
0000010111111100\
|
||||
0000010100000000\
|
||||
0111110111100000\
|
||||
0100000000100000\
|
||||
0111110111100000\
|
||||
0000010100000000\
|
||||
0000011100000000\
|
||||
";
|
||||
return msg;
|
|
@ -1,12 +0,0 @@
|
|||
msg.payload="\
|
||||
0001110011111100\
|
||||
0010010010000100\
|
||||
0100010010000100\
|
||||
0100110010110100\
|
||||
0101000100110100\
|
||||
0100111001010100\
|
||||
0100000001010100\
|
||||
0010000001010100\
|
||||
0001111110011100\
|
||||
";
|
||||
return msg;
|
|
@ -1,12 +0,0 @@
|
|||
msg.payload="\
|
||||
0001111111110000\
|
||||
0010000000001000\
|
||||
0100000000000100\
|
||||
0101111011100100\
|
||||
0101001010010100\
|
||||
0101001010010100\
|
||||
0100110010100100\
|
||||
0010000010101000\
|
||||
0001111100110000\
|
||||
";
|
||||
return msg;
|
|
@ -1,12 +0,0 @@
|
|||
msg.payload="\
|
||||
0000000000011100\
|
||||
0000000000010100\
|
||||
0111111100010100\
|
||||
0100000010010100\
|
||||
0111110001010100\
|
||||
0000001000110100\
|
||||
0000000100000100\
|
||||
0000000010000100\
|
||||
0000000001111100\
|
||||
";
|
||||
return msg;
|
|
@ -1,12 +0,0 @@
|
|||
msg.payload="\
|
||||
0001110001110000\
|
||||
0010001010001000\
|
||||
0100100100100100\
|
||||
0101010001010100\
|
||||
0101010001010100\
|
||||
0101010001010100\
|
||||
0100100100100100\
|
||||
0010001010001000\
|
||||
0001110001110000\
|
||||
";
|
||||
return msg;
|
|
@ -1,12 +0,0 @@
|
|||
msg.payload="\
|
||||
0001100111110000\
|
||||
0010101000001000\
|
||||
0100101001100100\
|
||||
0101001010010100\
|
||||
0101001010010100\
|
||||
0100111011110100\
|
||||
0100000000000100\
|
||||
0010000000001000\
|
||||
0001111111110000\
|
||||
";
|
||||
return msg;
|
Loading…
Reference in New Issue