IplImage结构文档描述了该IplROI* roi
插槽,它似乎是指向IplROI struct
核心types_c.h
头文件中定义的指针:
typedef struct _IplROI
{
int coi; /* 0 - no COI (all channels are selected)
, 1 - 0th channel is selected ...*/
int xOffset;
int yOffset;
int width;
int height;
}IplROI;
但它也描述了IplImage* maskROI
插槽,并且在核心types_c.h
文件中没有 typedef 结构......
如果有人可以帮助我找到它,我将不胜感激,但我确实 grep 了整个 opencv 下载,但一无所获.....我试图用 lisp 包装 IplImage 结构,我用 swig 包装它并得到了这个
(cffi:defcstruct ipl-image
(n-size :int)
(id :int)
(n-channels :int)
(alpha-channel :int)
(depth :int)
(color-model :pointer)
(channel-seq :pointer)
(data-order :int)
(origin :int)
(align :int)
(width :int)
(height :int)
(roi (:pointer (:struct ipl-roi)))
(mask-roi :pointer)
(image-id :pointer)
(tile-info :pointer)
(image-size :int)
(image-data :string)
(width-step :int)
(border-mode :pointer)
(border-const :pointer)
(image-data-origin :string))
我在这里改变了一点
(cffi:defcstruct ipl-image
(n-size :int)
(id :int)
(n-channels :int)
(alpha-channel :int)
(depth :int)
(color-model :int) ;;Ignored by OpenCV - was :pointer,
changed to :int so the struct values
would match OpenCV's
(channel-seq :int) ;;Ignored by OpenCV - was :pointer,
changed to :int so the struct values
would match OpenCV's
(data-order :int)
(origin :int)
(align :int)
(width :int)
(height :int)
(roi (:pointer (:struct ipl-roi))) ;; changed so i could access (:struct ipl-roi)
(mask-roi :pointer)
(image-id :pointer)
(tile-info :pointer)
(image-size :int)
(image-data :string)
(width-step :int)
(border-mode :pointer)
(border-const :pointer)
(image-data-origin :string))
因此,当我在 emacs 中运行以下代码(显示输出)时,所有插槽值都将与来自完全相同代码的 opencv 输出匹配,它们会这样做,因此我可以使用 ipl-image 结构访问 ipl-roi 结构线
(roi (:pointer (:struct ipl-roi))) ;;
因为我的直觉告诉我这是正确的方式
; SLIME 2012-05-25
CL-OPENCV> (size-of '(:struct ipl-image))
128
CL-OPENCV> (defparameter img-size (make-size :width 640 :height 480))
(defparameter img (create-image img-size +ipl-depth-8u+ 3))
IMG
CL-OPENCV> (cffi:with-foreign-slots ((n-size id n-channels
alpha-channel depth color-model
channel-seq data-order origin
align width height roi
mask-roi image-id tile-info
image-size image-data width-step
border-mode border-const image-data-origin)
img (:struct ipl-image))
(format t "n-size = ~a~%id = ~a~%n-channels =
~a~%alpha-channel = ~a~%depth = ~a~%color-model =
~a~%channel-seq = ~a~%data-order = ~a~%origin = ~
a~%align = ~a~%width = ~a~%height = ~a~%roi = ~a~
%mask-roi = ~a~%image-id = ~a~%tile-info = ~a~%
image-size = ~a~%image-data = ~a~%width-step =
~a~%border-mode = ~a~%border-const = ~a~%image-
data-origin = ~a~%"
n-size id n-channels
alpha-channel depth color-model
channel-seq data-order origin
align width height roi
mask-rOI image-id tile-info
image-size image-data width-step
border-mode border-const image-data-origin))
n-size = 144
id = 0
n-channels = 3
alpha-channel = 0
depth = 8
color-model = 4343634
channel-seq = 5392194
data-order = 0
origin = 0
align = 4
width = 640
height = 480
roi = #.(SB-SYS:INT-SAP #X00000000)
mask-roi = #.(SB-SYS:INT-SAP #X00000000)
image-id = #.(SB-SYS:INT-SAP #X00000000)
tile-info = #.(SB-SYS:INT-SAP #X00000000)
image-size = 921600
image-data =
width-step = 1920
border-mode = #.(SB-SYS:INT-SAP #X00000000)
border-const = #.(SB-SYS:INT-SAP #X00000000)
image-data-origin = NIL
NIL
CL-OPENCV>
但是对于 IplImage* maskROI 插槽,没有要包装的结构,所以我希望有人能给我一个关于如何包装包含 CFFI 中的结构指针的结构的快速课程,如果我认为这一行是正确的
(roi (:pointer (:struct ipl-roi)))
是正确的做法以及如何使用它
我真的很感激这方面的任何帮助
编辑