nakkaya / vision

OpenCV wrapper for Clojure
http://nakkaya.com/vision.html
132 stars 17 forks source link

IplImage from java.awt.image.BufferedImage #10

Open arronmabrey opened 9 years ago

arronmabrey commented 9 years ago

Hi @nakkaya,

I'm looking to use the template_matching functionality, like in the example https://github.com/nakkaya/vision/blob/master/resources/examples/template_match.clj

(ns template-match
  (:use [vision core] :reload-all))

(let [raw (load-image "resources/samples/template-input.png" :color)
      template (load-image "resources/samples/template-match.png" :color)
      [width height] (image-size template)
      [min max min-x min-y max-x max-y] (match-template raw template :ccorr-normed)]
  (rectangle raw [max-x max-y] [(+ max-x width) (+ max-y height)] java.awt.Color/blue 2)
  (view :result raw))

The difference being, for the raw image, I already have an instance of java.awt.image.BufferedImage that exists only in memory (the image is not persisted on disk).

Is it possible to create an instance IplImage from the BufferedImage, preferable without copying the bits?

-- Arron