       (let [picture         (.displayPicture (.priv_data context))
             width           (.imageWidth picture)
             height          (.imageHeight picture)
-            picture-buffer  (int-array (* width height))]
+            picture-buffer  (int-array (* width height))
+            image           (BufferedImage. width height BufferedImage/TYPE_INT_RGB)]
         (FrameUtils/YUV2RGB picture picture-buffer)
-        (buffer->image width height picture-buffer)))))
+        (.setRGB image 0 0 width height picture-buffer 0 width)
+        image))))
 
 (defn open-socket ^Socket []
   (doto (Socket.)
     (.setSoTimeout 2000)
-    (.connect (InetSocketAddress. "localhost" #_ comm/drone-ip 5555))))
+    (.connect (InetSocketAddress. #_ "localhost" comm/drone-ip 5555))))
 
 (defn save [^OutputStream out data]
   (doseq [[buffer size] data]

    (when (< (inc i) size) (recur (inc i))))
  target)

(defn buffer->image ^BufferedImage [^Long w ^Long h ^ints buffer]
  (let [image (BufferedImage. w h BufferedImage/TYPE_INT_RGB)]
    (.setRGB image 0 0 w h buffer 0 w)
    image))

(defn read-buffer [^InputStream in ^bytes buffer ^long offset ^long size]
  (IOUtils/readFully in buffer offset size))

(defn make-reader [^InputStream in]

              (Thread/sleep 1000))
            (finally
              (try (.close socket) (catch Exception _))
              (try (.close ^OutputStream out) (catch Exception _))))))
      (catch Throwable e
        (println "exception while processing video stream" e)
        (.printStackTrace e))
