added python script

python script to convert image data to height/color data
This commit is contained in:
Charles Mangin 2021-03-05 09:16:41 -05:00 committed by GitHub
parent fdd0087417
commit 96240f6677
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 0 deletions

27
canyon.py Normal file
View File

@ -0,0 +1,27 @@
import sys
import cv2
import struct
import time
import shutil
import subprocess
count = 0
height = open("canyon-120-px-4bit-height.hex","rb")
color = open("canyon-120-px-4bit-color.hex","rb")
file = open("CANYONDATA","wb")
heightbyte = bytearray(height.read(1))
colorbyte = bytearray(color.read(1))
while heightbyte:
byte = int(heightbyte[0]) + int(colorbyte[0])
packedbyte = struct.pack("B", byte)
file.write(packedbyte)
colorbyte = bytearray(color.read(1))
heightbyte = bytearray(height.read(1))
height.close()
color.close()
file.close()