      (when-not (nil? camera)
        (.release camera))))
 
-#_(q/defsketch videotest
+(q/defsketch videotest
   :title "Video Test"
   :size [WIDTH HEIGHT]
   :setup setup

  (:import
   [org.opencv.highgui Highgui VideoCapture]
   [org.opencv.core CvType Mat]
   [java.nio ByteBuffer]))

(def WIDTH 640)
(def HEIGHT 480)

            (update-in [:frame-mat] (partial grab-frame! camera) ))))

(defn mat->p-img [mat b-array i-array p-img]
  (let [n-mat (Mat. WIDTH HEIGHT CvType/CV_8UC4)]
    (Imgproc/cvtColor mat n-mat Imgproc/COLOR_BGRA2RGBA 0)
    (.get n-mat 0 0 b-array)
    (-> (ByteBuffer/wrap b-array)
       (.asIntBuffer)
       (.get i-array)))
  (.loadPixels p-img)
  (set! (.pixels p-img) (aclone i-array))
  (.updatePixels p-img)
  p-img)

(defn update-p-image [state]
