Closed zendevil closed 4 years ago
I completely missed this update ! Sorry, will answer very soon.
; we start by creating a 3x3 mat, where each pixel value
; is made of 1 channel, so CV_8UC1.
(def mat (new-mat 3 3 CV_8UC1))
; let's see what the inside of the mat looks like with dump
; dump just prints out the content,
; and returns nil
(dump mat)
; [0 0 0]
; [0 0 0]
; [0 0 0]
; nil
; we can retrieve the content as byte array using << on the mat
(<< mat)
; #object["[B" 0x33a36d5d "[B@33a36d5d"]
; it's hard to read what the byte array is,
; so in clojure we can make a sequence out of it.
(seq (<< mat))
; (0 0 0 0 0 0 0 0 0)
; let's replace the value in the mat,
; by using the function >>,
; that puts values inside the mat
; using a byte array, here created from a range.
(>> mat (byte-array (range 9)))
; we can check the values again using seq and <<
(seq (<< mat))
; (0 1 2 3 4 5 6 7 8)
; to multiply the content of the mat,
; you can use, multiply! and a scalar.
(multiply! mat (new-scalar 2.0))
; we can check the values again using seq and <<,
; and see that each value of the mat,
; has been multiplied by 2
(seq (<< mat))
; (0 2 4 6 8 10 12 14 16)
Added a jupyter notebook with the above code:
https://github.com/hellonico/origami-fun/blob/master/jupyter/simple_mats.ipynb
probably good, so closing since one month opened. Open a new ticket if you need some more info !
There doesn't seem to be an easy way to convert a mat object to a clojure vector for debugging. Also, for doing as something as multiplying a scalar with a mat, what does one do, this?:
Are there any good ways to do this?