diff --git a/42.png b/42.png new file mode 100644 index 0000000..9a7847f Binary files /dev/null and b/42.png differ diff --git a/libcaca/caca/dither.c b/libcaca/caca/dither.c index 911469e..34b9cee 100644 --- a/libcaca/caca/dither.c +++ b/libcaca/caca/dither.c @@ -15,6 +15,7 @@ */ #include "config.h" +#include #if !defined(__KERNEL__) # if defined(HAVE_ENDIAN_H) @@ -86,8 +87,8 @@ static int const rgb_weight[] = /* List of glyphs */ static uint32_t ascii_glyphs[] = { - // ' ', '.', ':', ';', 't', '%', 'S', 'X', '@', '8', '?' - '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' + ' ', '.', ':', ';', 't', '%', 'S', 'X', '@', '8', '?' + // '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' }; static uint32_t shades_glyphs[] = @@ -1183,9 +1184,8 @@ int caca_dither_bitmap(caca_canvas_t *cv, int x, int y, int w, int h, } /* Now output the character */ + // printf("%d, %d, %d, %d\r\n", x, y, w, h); // HERE TIMO caca_set_color_ansi(cv, outfg, outbg); - if (x == 5) - outch = '?'; caca_put_char(cv, x, y, outch); d->increment_dither(); diff --git a/track_hand.py b/track_hand.py index 7bc1d3e..b4d4bd9 100755 --- a/track_hand.py +++ b/track_hand.py @@ -21,16 +21,42 @@ def main() -> NoReturn: # pTime = 0 # cTime = 0 + img = cv2.imread("42.png", 0) + if len(img.shape) == 2 or img.shape[2] == 1: + img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) + img = cv2.flip(img, 1) + + height, width, _ = img.shape + margin = 100 + top_margin = margin + 20 + bottom_margin = margin + 20 + left_margin = margin + right_margin = margin + img = img[top_margin:height-bottom_margin, left_margin:width-right_margin] + + side_length = min(640, 480) // 3 + overlay_resized = cv2.resize(img, (side_length, side_length)) + print(repr(overlay_resized)) + input() + sys.exit() + while True: success, frame = cap.read() + if not success: + continue + imgRGB = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) results = hands.process(imgRGB) + h, w, c = frame.shape + + img_x, img_y = 10, 10 + frame[img_y:img_y+side_length, img_x:img_x+side_length] = overlay_resized + if results.multi_hand_landmarks: for handLms in results.multi_hand_landmarks: visited_7 = False for id, lm in enumerate(handLms.landmark): - h, w, c = frame.shape cx = int(lm.x * w) cy = int(lm.y * h) # 7 one-before-index, 8 index, 4 thumb, 0 base @@ -73,9 +99,6 @@ def main() -> NoReturn: # cv2.putText(frame, str(int(fps)), (10,70), cv2.FONT_HERSHEY_PLAIN, 3, (255, 0, 255), 3) - - if not success: - continue sys.stdout.buffer.write(frame.tobytes()) # cv2.imshow("Image", frame) # cv2.waitKey(1) diff --git a/working_command.sh b/working_command.sh index d19fecb..95d286d 100755 --- a/working_command.sh +++ b/working_command.sh @@ -1,7 +1,5 @@ #!/bin/sh -# st -f 'SauceCodePro Nerd Font Mono' -e sh -c '2>/dev/null ffmpeg -re -i /dev/video0 -noautoscale -map 0:V:0 -filter:v "fps=fps=30,format=gray,hflip" -c:v libx265 -preset ultrafast -tune zerolatency -crf 30 -f nut - | TERM=xterm-mono CACA_DRIVER=ncurses DISPLAY= mpv --really-quiet --no-cache --no-config --vo=caca --untimed --profile=low-latency --fps=30 -' - -# xterm -bg black -fg white -s -fullscreen -fa 'SauceCodePro Nerd Font Mono' -fs 8 -e '2>/dev/null ffmpeg -re -i /dev/video0 -noautoscale -map 0:V:0 -filter:v "fps=fps=30,format=gray,hflip" -c:v libx265 -preset ultrafast -tune zerolatency -crf 30 -f nut - | TERM=xterm-mono CACA_DRIVER=ncurses DISPLAY= mpv --really-quiet --no-cache --no-config --vo=caca --untimed --profile=low-latency --fps=30 -; read X' - -# st -f 'SauceCodePro Nerd Font Mono' -e sh -c '{ 2>/dev/null ./track_hand.py | 2>/dev/null ffmpeg -y -f rawvideo -s 640x480 -pix_fmt bgr24 -i - -map 0:V:0 -filter:v "format=gray,hflip" -c:v libx264 -preset ultrafast -tune zerolatency -crf 30 -f nut - | TERM=xterm-mono CACA_DRIVER=ncurses DISPLAY= mpv --really-quiet --no-cache --no-config --vo=tct --untimed --profile=low-latency - || { echo Error 1>&2; read X; }; }' -st -f 'SauceCodePro Nerd Font Mono' -e sh -c '{ 2>/dev/null ./track_hand.py | 2>/dev/null ffmpeg -y -f rawvideo -s 640x480 -pix_fmt bgr24 -i - -map 0:V:0 -filter:v "hflip" -c:v libx265 -preset ultrafast -tune zerolatency -crf 30 -f nut - | TERM=xterm-mono CACA_DRIVER=ncurses DISPLAY= mpv --really-quiet --no-cache --no-config --vo=caca --untimed --profile=low-latency - || { echo Error 1>&2; read X; }; }' +# xterm -bg black -fg white -s -fullscreen -fa 'SauceCodePro Nerd Font Mono' -fs 8 -e '{ ./track_hand.py | 2>/dev/null ffmpeg -y -f rawvideo -s 640x480 -pix_fmt bgr24 -i - -map 0:V:0 -filter:v "format=gray,hflip" -c:v libx264 -preset ultrafast -tune zerolatency -crf 30 -f nut - | TERM=xterm-mono CACA_DRIVER=ncurses DISPLAY= mpv --really-quiet --no-cache --no-config --vo=caca --untimed --profile=low-latency - || { echo Error 1>&2; read X; }; }' +# st -f 'SauceCodePro Nerd Font Mono:size=10' -e sh -c '{ ./track_hand.py | 2>/dev/null ffmpeg -y -f rawvideo -s 640x480 -pix_fmt bgr24 -i - -map 0:V:0 -filter:v "format=gray,hflip" -c:v libx265 -preset ultrafast -tune zerolatency -crf 30 -f nut - | TERM=xterm-mono CACA_DRIVER=ncurses DISPLAY= mpv --really-quiet --no-cache --no-config --vo=caca --untimed --profile=low-latency - || { echo Error 1>&2; read X; }; } | ./game.py' +st -f 'SauceCodePro Nerd Font Mono:size=10' -e sh -c '{ ./track_hand.py | 2>/dev/null ffmpeg -y -f rawvideo -s 640x480 -pix_fmt bgr24 -i - -map 0:V:0 -filter:v "format=gray,hflip" -c:v libx265 -preset ultrafast -tune zerolatency -crf 30 -f nut - | TERM=xterm-mono CACA_DRIVER=ncurses DISPLAY= mpv --really-quiet --no-cache --no-config --vo=caca --untimed --profile=low-latency - || { echo Error 1>&2; read X; }; }' +# st -f 'SauceCodePro Nerd Font Mono:size=10' -e sh -c '{ ./track_hand.py | 2>/dev/null ffmpeg -y -f rawvideo -s 640x480 -pix_fmt bgr24 -i - -map 0:V:0 -filter:v "format=gray,hflip" -c:v libx264 -preset ultrafast -tune zerolatency -crf 30 -f nut - | TERM=xterm-mono CACA_DRIVER=ncurses DISPLAY= mpv --really-quiet --no-cache --no-config --vo=tct --untimed --profile=low-latency - || { echo Error 1>&2; read X; }; }'