コード例 #1
0
ファイル: cvaux.go プロジェクト: bradhe/go-opencv
func (self *HaarClassifierCascade) DetectObjects(image *IplImage, storage *MemStorage, scale float64, minNeighbors, flags int, minSize, maxSize Size) []*Rect {
	c_storage := (*C.CvMemStorage)(storage)
	c_self := (*C.CvHaarClassifierCascade)(self)

	c_seq := C.cvHaarDetectObjects(
		unsafe.Pointer(image),
		c_self,
		c_storage,
		C.double(scale),
		C.int(minNeighbors),
		C.int(flags),
		C.cvSize(C.int(minSize.Width), C.int(minSize.Height)),
		C.cvSize(C.int(maxSize.Width), C.int(maxSize.Height)),
	)

	seq := (*Seq)(c_seq)

	var arr []*Rect
	var r Rect

	seq.ForEach(reflect.TypeOf(r), func(obj interface{}) {
		arr = append(arr, obj.(*Rect))
	})

	return arr
}
コード例 #2
0
ファイル: cvaux.go プロジェクト: harshavardhana/go-opencv
func (this *HaarCascade) DetectObjects(image *IplImage) []*Rect {
	storage := C.cvCreateMemStorage(0)
	seq := C.cvHaarDetectObjects(unsafe.Pointer(image), this.cascade, storage, 1.1, 3, C.CV_HAAR_DO_CANNY_PRUNING, C.cvSize(0, 0), C.cvSize(0, 0))
	var faces []*Rect
	for i := 0; i < (int)(seq.total); i++ {
		rect := (*Rect)((*_Ctype_CvRect)(unsafe.Pointer(C.cvGetSeqElem(seq, C.int(i)))))
		faces = append(faces, rect)
	}
	return faces
}
コード例 #3
0
ファイル: main.go プロジェクト: masu-mi/face_detector
func detect(tarImg *C.IplImage) *C.CvSeq {
	cvHCC := (*C.CvHaarClassifierCascade)(
		C.cvLoad(C.CString("./config/haarcascade_frontalface_default.xml"),
			(*C.CvMemStorage)(nil),
			(*C.char)(nil),
			(**C.char)(nil)))
	cvMStr := C.cvCreateMemStorage(0)

	return C.cvHaarDetectObjects(
		unsafe.Pointer(tarImg),
		cvHCC,
		cvMStr,
		1.11,
		3,
		0,
		C.cvSize(0, 0),
		C.cvSize(0, 0),
	)
}