           {}
           (partition 2 triangle-points)))
 
+(defn mat
+  ([]
+     (Mat.))
+  ([h w t]
+     (Mat. (int h) (int w) t)))
+
 ;; bArray is the temporary byte array buffer for OpenCV cv::Mat.
 ;; iArray is the temporary integer array buffer for PImage pixels.
 (defn setup []

        tri-glyphs (triangle-glyphs tri-pts tri-orients)]
   {:b-array (byte-array PIX-CNT1)
    :i-array (int-array PIX-CNT2)
    :frame-mat (Mat. HEIGHT WIDTH CvType/CV_8UC3)
    :output-mat (Mat. HEIGHT WIDTH CvType/CV_8UC4)
    :gray-mat (Mat.)
    :rgba-mat (Mat.)
    :drawn-mat (Mat. HEIGHT WIDTH CvType/CV_8UC4)
    :camera (cv/camera CAM-DEV-NUM)
    :p-image (q/create-image WIDTH HEIGHT :rgb)
    :triangle-points tri-pts
    :triangle-orientations tri-orients
    :triangle-glyphs tri-glyphs}))

        (partition 2 triangle-points)))
  state)

(defn update-drawn-p-image [state]
  (let [{:keys [drawn-mat output-mat b-array i-array]} state]
    (update-in state [:p-image] #(cv/mat->p-img drawn-mat output-mat b-array i-array %))))
