Beispiel #1
0
func imageFromIplImage(iplImage *C.IplImage) (*Image, error) {
	image := new(Image)
	image.ptr = unsafe.Pointer(iplImage)
	image.iplImage = iplImage
	image.Initialized = true

	size := C.cvGetSize(image.ptr)
	image.size = Size{int(size.width), int(size.height)}
	image.imtype = typeFromDepthAndChannels(iplImage.depth, iplImage.nChannels)

	if image.imtype.NumChannels == 1 {
		image.colorModel = color.GrayModel
	} else if image.imtype.NumChannels == 3 {
		image.colorModel = color.RGBAModel
	} else {
		panic("Unsupported image type - Unsupported number of channels")
	}

	return image, nil
}
Beispiel #2
0
func GetSize(img *IplImage) Size {
	sz := C.cvGetSize(unsafe.Pointer(img))
	return Size{int(sz.width), int(sz.height)}

}
Beispiel #3
0
func GetSizeHeight(img *IplImage) int {
	size := C.cvGetSize(unsafe.Pointer(img))
	w := int(size.height)
	return w
}
Beispiel #4
0
/* Returns width and height of array in elements */
func GetSizeWidth(img *IplImage) int {
	size := C.cvGetSize(unsafe.Pointer(img))
	w := int(size.width)
	return w
}