Last active
June 16, 2016 19:59
-
-
Save wedesoft/f0d0065f45fb401ba7bb192716448477 to your computer and use it in GitHub Desktop.
HornetsEye, OpenCV, RMagick conversions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'multiarray' | |
require 'hornetseye_opencv' | |
require 'hornetseye_rmagick' | |
require 'hornetseye_narray' | |
include Hornetseye | |
img = MultiArray[[2, 3, 5, 7], [11, 13, 17, 19]] | |
# MultiArray(UBYTE,2): | |
# [ [ 2, 3, 5, 7 ], | |
# [ 11, 13, 17, 19 ] ] | |
cvmat = img.to_cvmat | |
# #<OpenCV::CvMat:0x00000002650ac0> | |
cvmat.to_multiarray | |
# MultiArray(UBYTE,2): | |
# [ [ 2, 3, 5, 7 ], | |
# [ 11, 13, 17, 19 ] ] | |
narray = img.to_narray | |
# NArray.byte(4,2): | |
# [ [ 2, 3, 5, 7 ], | |
# [ 11, 13, 17, 19 ] ] | |
narray.to_multiarray | |
# MultiArray(UBYTE,2): | |
# [ [ 2, 3, 5, 7 ], | |
# [ 11, 13, 17, 19 ] ] | |
rmagick = img.to_magick | |
# 4x2 DirectClass 8-bit | |
rmagick.to_multiarray | |
# MultiArray(UBYTE,2): | |
# [ [ 2, 3, 5, 7 ], | |
# [ 11, 13, 17, 19 ] ] | |
memory = img.memory | |
# Malloc(8) | |
str = memory.read(memory.size) | |
# "\x02\x03\x05\a\v\r\x11\x13" | |
img = MultiArray.import(UBYTE, str, 4, 2) | |
# MultiArray(UBYTE,2): | |
# [ [ 2, 3, 5, 7 ], | |
# [ 11, 13, 17, 19 ] ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment