    [quil.middleware :as m]
    [videotest.cv-blob.cv :as cv])
   (:import
-   [org.opencv.core CvType Mat Size]
-   [org.opencv.features2d FeatureDetector]
+   [org.opencv.core CvType Mat MatOfKeyPoint Point Size]
+   [org.opencv.features2d FeatureDetector KeyPoint]
    [org.opencv.imgproc Imgproc]
    [java.nio ByteBuffer ByteOrder]))
 
-;; Based on Blobscanner example sketch by Antonio Molinaro:
-;; https://github.com/robdanet/blobscanner/blob/master/examples/blob_centroid/findCentroids/findCentroids.pde
-;;
-;; 
 
 (def CAM-SIZE (cv/camera-frame-size))
 (def WIDTH  (int (:width  CAM-SIZE)))

      (cv/update-frame)
      (update-gray-mat)
      (update-gray-p-image)
      #_(update-blobs)))

(defn draw-centroid [detector n]
  (q/ellipse (.getCentroidX detector n)
             (.getCentroidY detector n)
             40 40))

(defn draw-centroids [{:keys [detector]}]
  (when (and detector
             (< 0 (.getBlobsNumber detector)))
    (q/push-style)
    (q/no-stroke)
    (q/fill 0 255 0 80)
    (dorun
     (map #(draw-centroid detector %)
          (range 0 (.getBlobsNumber detector))))
    (q/pop-style)))

(defn draw [state]
  (let [{:keys [p-image]} state]

    (update-in state [:p-image] #(cv/gray-mat->p-img gray-mat output-mat b-array i-array %))
    state))

(defn update-blobs [{:keys [detector gray-mat blob-points] :as state}]
  (when gray-mat
    (.detect detector gray-mat blob-points))
  state)

(defn update [state]
