Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply formatter (black) and add credits #18

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions reverse_engineering/icon_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
import os

sys.path.insert(1, '../src')
sys.path.insert(1, "../src")
from TJC3224 import TJC3224_LCD

"""
Expand All @@ -15,14 +15,16 @@
with following name "<LIBID>_<ICONID>.jpg>.
"""

save_folder='icon_database_fw_1_0_6'
com_port = 'COM3'
save_folder = "icon_database_fw_1_0_6"
com_port = "COM3"
baud_rate = 115200
screen_width = 240
screen_height = 320
delay_between_loops_in_s = 0.1 # A better webcam connected via usb can have a shorter delay
delay_between_loops_in_s = (
0.1 # A better webcam connected via usb can have a shorter delay
)

screen = TJC3224_LCD(com_port,baud_rate)
screen = TJC3224_LCD(com_port, baud_rate)
cam = cv2.VideoCapture(0)

if not cam.isOpened():
Expand All @@ -33,30 +35,30 @@

# Create a save directory if it does not exist
if not os.path.exists(save_folder):
os.makedirs(save_folder)
os.makedirs(save_folder)

for lib_id in range (0,65):
for icon_id in range (255):
for lib_id in range(0, 65):
for icon_id in range(255):
screen.clear_screen(screen.color_white)
screen.draw_icon(lib_id, icon_id, screen_width//5, screen_height//4)
screen.draw_icon(lib_id, icon_id, screen_width // 5, screen_height // 4)
# Give some time to make sure the camera feed sees the icon (as my wifi camera has a delay)
time.sleep(delay_between_loops_in_s)
# Capture frame from camera
ret, frame = cam.read()
if not ret:
print("Error: Could not capture frame.")
raise Exception("Error: Could not capture frame.")

# Resize the frame to save space
frame = imutils.resize(frame, width=200)
image_name = str(lib_id)+"_"+str(icon_id)+".jpg"
image_name = str(lib_id) + "_" + str(icon_id) + ".jpg"
image_path = os.path.join(save_folder, image_name)
# Save the image
cv2.imwrite(image_path, frame)

print(f"Saving {image_name}")
images_saved += 1

# Release the webcam
cam.release()
print(f"Finish! {images_saved} images were saved in folder {save_folder}")
Loading