From 81896ba400c77d42f7ca40c1b62687bd67ce536a Mon Sep 17 00:00:00 2001 From: heyarne Date: Sat, 2 May 2020 22:20:28 +0200 Subject: [PATCH] Use smaller capture size for mobile --- src/heyarne/all_my_friends/core.cljs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/heyarne/all_my_friends/core.cljs b/src/heyarne/all_my_friends/core.cljs index 9e29e63..e229029 100644 --- a/src/heyarne/all_my_friends/core.cljs +++ b/src/heyarne/all_my_friends/core.cljs @@ -70,6 +70,7 @@ (set! (.-onloadedmetadata video-elem) #(resolve video-elem))))) ;; TODO: Handle rejected permission request +;; TODO: Initialize model in the background (defn init [] (swap! state ::status :webcam-init) @@ -85,8 +86,7 @@ ;; initialize canvas (set! (.-width canvas) (.-videoWidth video)) (set! (.-height canvas) (.-videoHeight video)) - #_(.translate ctx (.-width canvas) 0) - #_(.scale ctx -1 1) + #_(.scale ctx (/ (.-clientWidth video) (.-videoWidth video)) (/ (.-clientHeight video) (.-videoHeight video))) ;; initalize model (swap! state ::status :model-init) @@ -95,6 +95,8 @@ (then #(.load facemesh #js {:maxFaces 1})) (then #(detect-faces % video)))))))) +(.-clientWidth (.querySelector js/document "video#capture")) + (defonce initialize (init) #_(do (println "Initializing…")