IplImage struct documentation描述了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中包含包含结构指针的结构的快速课程,如果我正确地想到这一行< / p>
(roi (:pointer (:struct ipl-roi)))
是正确的做法和如何使用
我真的会对此提供任何帮助
修改
答案 0 :(得分:0)
Blimey这个问题太长了!
无论如何,这个cffi领域的官方文档非常糟糕。 我建议looking at this file for lots of examples of different kinds of structs with various contents
例如:
(cffi:defcstruct ai-node-anim ;; this is a definition of a c struct
(m-node-name (:struct ai-string))
(m-num-position-keys :unsigned-int)
(m-position-keys (:pointer (:struct ai-vector-key))) ;; here is a pointer to a struct
(m-num-rotation-keys :unsigned-int)
(m-rotation-keys (:pointer (:struct ai-quat-key))) ;; here is a pointer to a struct
(m-num-scaling-keys :unsigned-int)
(m-scaling-keys (:pointer (:struct ai-vector-key))) ;; here is a pointer to a struct
(m-pre-state ai-anim-behaviour)
(m-post-state ai-anim-behaviour))
希望它有所帮助!