Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Commit

Permalink
Improved the graphical interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Felecort committed Jan 22, 2021
1 parent 7558701 commit d34f183
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,46 @@ def pixel_video(video, pixel_size):

# Pixel art of a single image
def image_pixel_art():
canvas_progress.update()
canvas_progress.create_rectangle(0, 0, 250, 50, fill="#33cccc", width=0)
pixel_size = int(entry_pixel_size.get())
image_name = selecting_file()
if image_name == '':
print('missing the input image')
canvas_progress.update()
canvas_progress.create_text(125, 17,
text="Изображение отсутствует",
font=("Arial", 12, "bold"),
fill="#000000")
return 0
image = cv2.imread(image_name)
pixel_img = conversion_to_pixel(image, pixel_size)
canvas_progress.update()
canvas_progress.create_text(125, 17,
text="Успешно!",
font=("Arial", 12, "bold"),
fill="#000000")
draw_image(pixel_img, image_name, pixel_size)


# Pixelation of video and output to the screen
def video_pixel_art():
canvas_progress.update()
canvas_progress.create_rectangle(0, 0, 250, 50, fill="#33cccc", width=0)
pixel_size = int(entry_pixel_size.get())
video_name = selecting_file()
if video_name == '':
print('missing the input video')
canvas_progress.update()
canvas_progress.create_text(125, 17,
text="Видео отсутствует",
font=("Arial", 12, "bold"),
fill="#000000")
return 0
elif video_name[-3:] != "mp4":
print("only mp4 videos are supported")
canvas_progress.update()
canvas_progress.create_text(125, 17,
text="Неподдерживаемый формат файла",
font=("Arial", 10, "bold"),
fill="#000000")
return 0
canvas_progress.update()
canvas_progress.create_rectangle(0, 0, 250, 50, fill="#33cccc", width=0)
Expand Down Expand Up @@ -124,7 +145,7 @@ def video_pixel_art():
count_frames += 1
image = conversion_to_pixel(frame, pixel_size)
out.write(image)
draw_progress(101)
draw_progress(100)
canvas_progress.update()
canvas_progress.create_text(125, 17,
text="Успешно!",
Expand All @@ -137,8 +158,15 @@ def video_pixel_art():

# Pixelate webcam video and display it on the screen
def webcam_pixel_art():
canvas_progress.update()
canvas_progress.create_rectangle(0, 0, 250, 50, fill="#33cccc", width=0)
pixel_size = int(entry_pixel_size.get())
video = cv2.VideoCapture(0, cv2.CAP_DSHOW)
canvas_progress.update()
canvas_progress.create_text(125, 17,
text="Успешно!",
font=("Arial", 12, "bold"),
fill="#000000")
pixel_video(video, pixel_size)


Expand Down Expand Up @@ -228,7 +256,7 @@ def webcam_pixel_art():
)
exit_button.place(x=20, y=350)

canvas_progress = Canvas(window, width=250, height=30, bg="#33cccc")
canvas_progress = Canvas(window, width=248, height=30, bg="#33cccc")
canvas_progress.place(x=330, y=50)

# Starting an infinite loop
Expand Down

0 comments on commit d34f183

Please sign in to comment.