import svn rep
6
AUTHORS
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Names should be added to this file like so:
|
||||||
|
# Name or Organization <email address>
|
||||||
|
|
||||||
|
# Initial version authors:
|
||||||
|
ChaiShushan <chaishushan@gmail.com>
|
||||||
|
|
||||||
16
INSTALL
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
Linux
|
||||||
|
1. install Go1 and OpenCV
|
||||||
|
2. go get code.google.com/p/go-opencv/trunk/opencv
|
||||||
|
3. cd ${GoOpenCVRoot}/trunk/samples && go run hellocv.go
|
||||||
|
|
||||||
|
Windows
|
||||||
|
1. install Go1 and MinGW
|
||||||
|
2. install OpenCV-2.4.x to MinGW dir
|
||||||
|
libopencv*.dll --> ${MinGWRoot}\bin
|
||||||
|
libopencv*.lib --> ${MinGWRoot}\lib
|
||||||
|
include\opencv --> ${MinGWRoot}\include\opencv
|
||||||
|
include\opencv2 --> ${MinGWRoot}\include\opencv2
|
||||||
|
2. go get code.google.com/p/go-opencv/trunk/opencv
|
||||||
|
3. cd ${GoOpenCVRoot}/trunk/samples && go run hellocv.go
|
||||||
|
|
||||||
27
LICENSE
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright (c) 2011-2012 The go-opencv Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
0
NEWS
Normal file
0
README
Normal file
0
TODO
Normal file
23550
data/haarcascades/haarcascade_frontalface_alt2.xml
Normal file
BIN
images/airplane.jpg
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
images/baboon.jpg
Normal file
|
After Width: | Height: | Size: 176 KiB |
BIN
images/fruits.jpg
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
images/lena.jpg
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
images/pic1.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
images/pic2.png
Normal file
|
After Width: | Height: | Size: 254 KiB |
BIN
images/pic3.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
images/pic4.png
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
images/pic5.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
images/pic6.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
images/stuff.jpg
Normal file
|
After Width: | Height: | Size: 29 KiB |
84
opencv/cv.go
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package opencv
|
||||||
|
|
||||||
|
//#include "opencv.h"
|
||||||
|
//#cgo linux pkg-config: opencv
|
||||||
|
//#cgo darwin pkg-config: opencv
|
||||||
|
//#cgo windows LDFLAGS: -lopencv_core242.dll -lopencv_imgproc242.dll -lopencv_photo242.dll -lopencv_highgui242.dll -lstdc++
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
//"errors"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_BGR2GRAY = C.CV_BGR2GRAY
|
||||||
|
|
||||||
|
CV_BLUR = C.CV_BLUR
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
/* Smoothes array (removes noise) */
|
||||||
|
func Smooth(src, dst *IplImage, smoothtype,
|
||||||
|
param1, param2 int, param3, param4 float64) {
|
||||||
|
C.cvSmooth(unsafe.Pointer(src), unsafe.Pointer(dst), C.int(smoothtype),
|
||||||
|
C.int(param1), C.int(param2), C.double(param3), C.double(param4),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
//CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst,
|
||||||
|
// int smoothtype CV_DEFAULT(CV_GAUSSIAN),
|
||||||
|
// int param1 CV_DEFAULT(3),
|
||||||
|
// int param2 CV_DEFAULT(0),
|
||||||
|
// double param3 CV_DEFAULT(0),
|
||||||
|
// double param4 CV_DEFAULT(0));
|
||||||
|
|
||||||
|
/* Converts input array pixels from one color space to another */
|
||||||
|
func CvtColor(src, dst *IplImage, code int) {
|
||||||
|
C.cvCvtColor(unsafe.Pointer(src), unsafe.Pointer(dst), C.int(code))
|
||||||
|
}
|
||||||
|
//CVAPI(void) cvCvtColor( const CvArr* src, CvArr* dst, int code );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Runs canny edge detector */
|
||||||
|
func Canny(image, edges *IplImage, threshold1, threshold2 float64, aperture_size int) {
|
||||||
|
C.cvCanny(unsafe.Pointer(image), unsafe.Pointer(edges),
|
||||||
|
C.double(threshold1), C.double(threshold2),
|
||||||
|
C.int(aperture_size),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
//CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1,
|
||||||
|
// double threshold2, int aperture_size CV_DEFAULT(3) );
|
||||||
|
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_INPAINT_NS = C.CV_INPAINT_NS
|
||||||
|
CV_INPAINT_TELEA = C.CV_INPAINT_TELEA
|
||||||
|
)
|
||||||
|
|
||||||
|
/* Inpaints the selected region in the image */
|
||||||
|
func Inpaint(src, inpaint_mask, dst *IplImage, inpaintRange float64, flags int) {
|
||||||
|
C.cvInpaint(
|
||||||
|
unsafe.Pointer(src),
|
||||||
|
unsafe.Pointer(inpaint_mask),
|
||||||
|
unsafe.Pointer(dst),
|
||||||
|
C.double(inpaintRange),
|
||||||
|
C.int(flags),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
//CVAPI(void) cvInpaint( const CvArr* src, const CvArr* inpaint_mask,
|
||||||
|
// CvArr* dst, double inpaintRange, int flags );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
95
opencv/cvaux.go
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package opencv
|
||||||
|
|
||||||
|
//#include "opencv.h"
|
||||||
|
//#cgo linux pkg-config: opencv
|
||||||
|
//#cgo darwin pkg-config: opencv
|
||||||
|
//#cgo windows LDFLAGS: -lopencv_core242.dll -lopencv_imgproc242.dll -lopencv_photo242.dll -lopencv_highgui242.dll -lstdc++
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Eigen objects *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* 1D/2D HMM *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************** Embedded HMMs *************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* A few functions from old stereo gesture recognition demosions *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Additional operations on Subdivisions *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* More operations on sequences *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************Stereo correspondence*************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************************/
|
||||||
|
/************ Epiline functions *******************/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Contour Morphing *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Texture Descriptors *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Face eyes&mouth tracking *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* 3D Tracker *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Skeletons and Linear-Contour Models *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Background/foreground segmentation *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Calibration engine *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************\
|
||||||
|
* --- END --- *
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
451
opencv/cxcore.go
Normal file
|
|
@ -0,0 +1,451 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package opencv
|
||||||
|
|
||||||
|
//#include "opencv.h"
|
||||||
|
//#cgo linux pkg-config: opencv
|
||||||
|
//#cgo darwin pkg-config: opencv
|
||||||
|
//#cgo windows LDFLAGS: -lopencv_core242.dll -lopencv_imgproc242.dll -lopencv_photo242.dll -lopencv_highgui242.dll -lstdc++
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
//"errors"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Array allocation, deallocation, initialization and access to elements *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
func Alloc(size int) unsafe.Pointer {
|
||||||
|
return unsafe.Pointer(C.cvAlloc(C.size_t(size)))
|
||||||
|
}
|
||||||
|
func Free(p unsafe.Pointer) {
|
||||||
|
C.cvFree_(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocates and initializes IplImage header */
|
||||||
|
func CreateImageHeader(w, h, depth, channels int) *IplImage {
|
||||||
|
hdr := C.cvCreateImageHeader(
|
||||||
|
C.cvSize(C.int(w),C.int(h)),
|
||||||
|
C.int(depth),
|
||||||
|
C.int(channels),
|
||||||
|
)
|
||||||
|
return (*IplImage)(hdr)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Inializes IplImage header */
|
||||||
|
func (img *IplImage)InitHeader(w, h, depth, channels, origin, align int) {
|
||||||
|
C.cvInitImageHeader(
|
||||||
|
(*C.IplImage)(img),
|
||||||
|
C.cvSize(C.int(w),C.int(h)),
|
||||||
|
C.int(depth),
|
||||||
|
C.int(channels),
|
||||||
|
C.int(origin),
|
||||||
|
C.int(align),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creates IPL image (header and data) */
|
||||||
|
func CreateImage(w, h, depth, channels int) *IplImage {
|
||||||
|
size := C.cvSize(C.int(w), C.int(h))
|
||||||
|
img := C.cvCreateImage(size, C.int(depth), C.int(channels))
|
||||||
|
return (*IplImage)(img)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Releases (i.e. deallocates) IPL image header */
|
||||||
|
func (img *IplImage)ReleaseHeader() {
|
||||||
|
img_c := (*C.IplImage)(img)
|
||||||
|
C.cvReleaseImageHeader(&img_c)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Releases IPL image header and data */
|
||||||
|
func (img *IplImage)Release() {
|
||||||
|
img_c := (*C.IplImage)(img)
|
||||||
|
C.cvReleaseImage(&img_c)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creates a copy of IPL image (widthStep may differ) */
|
||||||
|
func (img *IplImage)Clone() *IplImage {
|
||||||
|
p := C.cvCloneImage((*C.IplImage)(img))
|
||||||
|
return (*IplImage)(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets a Channel Of Interest (only a few functions support COI) -
|
||||||
|
use cvCopy to extract the selected channel and/or put it back */
|
||||||
|
func (img *IplImage)SetCOI(coi int) {
|
||||||
|
C.cvSetImageCOI((*C.IplImage)(img), C.int(coi))
|
||||||
|
}
|
||||||
|
/* Retrieves image Channel Of Interest */
|
||||||
|
func (img *IplImage)GetCOI() int {
|
||||||
|
coi := C.cvGetImageCOI((*C.IplImage)(img))
|
||||||
|
return int(coi)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets image ROI (region of interest) (COI is not changed) */
|
||||||
|
func (img *IplImage)SetROI(rect Rect) {
|
||||||
|
C.cvSetImageROI((*C.IplImage)(img), C.CvRect(rect))
|
||||||
|
}
|
||||||
|
/* Resets image ROI and COI */
|
||||||
|
func (img *IplImage)ResetROI() {
|
||||||
|
C.cvResetImageROI((*C.IplImage)(img))
|
||||||
|
}
|
||||||
|
/* Retrieves image ROI */
|
||||||
|
func (img *IplImage)GetROI() Rect {
|
||||||
|
r := C.cvGetImageROI((*C.IplImage)(img))
|
||||||
|
return Rect(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// mat step
|
||||||
|
const (
|
||||||
|
CV_AUTOSTEP = C.CV_AUTOSTEP
|
||||||
|
)
|
||||||
|
|
||||||
|
/* Allocates and initalizes CvMat header */
|
||||||
|
func CreateMatHeader(rows, cols, type_ int) *Mat {
|
||||||
|
mat := C.cvCreateMatHeader(
|
||||||
|
C.int(rows), C.int(cols), C.int(type_),
|
||||||
|
)
|
||||||
|
return (*Mat)(mat)
|
||||||
|
}
|
||||||
|
/* Allocates and initializes CvMat header and allocates data */
|
||||||
|
func CreateMat(rows, cols, type_ int) *Mat {
|
||||||
|
mat := C.cvCreateMat(
|
||||||
|
C.int(rows), C.int(cols), C.int(type_),
|
||||||
|
)
|
||||||
|
return (*Mat)(mat)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initializes CvMat header */
|
||||||
|
func (mat *Mat)InitHeader(rows, cols, type_ int, data unsafe.Pointer, step int) {
|
||||||
|
C.cvInitMatHeader(
|
||||||
|
(*C.CvMat)(mat),
|
||||||
|
C.int(rows),
|
||||||
|
C.int(cols),
|
||||||
|
C.int(type_),
|
||||||
|
data,
|
||||||
|
C.int(step),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Releases CvMat header and deallocates matrix data
|
||||||
|
(reference counting is used for data) */
|
||||||
|
func (mat *Mat)Release() {
|
||||||
|
mat_c := (*C.CvMat)(mat)
|
||||||
|
C.cvReleaseMat(&mat_c)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Decrements CvMat data reference counter and deallocates the data if
|
||||||
|
it reaches 0 */
|
||||||
|
func DecRefData(arr Arr) {
|
||||||
|
C.cvDecRefData(unsafe.Pointer(arr))
|
||||||
|
}
|
||||||
|
/* Increments CvMat data reference counter */
|
||||||
|
func IncRefData(arr Arr) {
|
||||||
|
C.cvIncRefData(unsafe.Pointer(arr))
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creates an exact copy of the input matrix (except, may be, step value) */
|
||||||
|
func (mat *Mat)Clone() *Mat {
|
||||||
|
mat_new := C.cvCloneMat((*C.CvMat)(mat))
|
||||||
|
return (*Mat)(mat_new)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Makes a new matrix from <rect> subrectangle of input array.
|
||||||
|
No data is copied */
|
||||||
|
func GetSubRect(arr Arr, submat *Mat, rect Rect) *Mat {
|
||||||
|
mat_new := C.cvGetSubRect(
|
||||||
|
unsafe.Pointer(arr),
|
||||||
|
(*C.CvMat)(submat),
|
||||||
|
(C.CvRect)(rect),
|
||||||
|
)
|
||||||
|
return (*Mat)(mat_new)
|
||||||
|
}
|
||||||
|
//#define cvGetSubArr cvGetSubRect
|
||||||
|
|
||||||
|
/* Selects row span of the input array: arr(start_row:delta_row:end_row,:)
|
||||||
|
(end_row is not included into the span). */
|
||||||
|
func GetRows(arr Arr, submat *Mat, start_row, end_row, delta_row int) *Mat {
|
||||||
|
mat_new := C.cvGetRows(
|
||||||
|
unsafe.Pointer(arr),
|
||||||
|
(*C.CvMat)(submat),
|
||||||
|
C.int(start_row),
|
||||||
|
C.int(end_row),
|
||||||
|
C.int(delta_row),
|
||||||
|
)
|
||||||
|
return (*Mat)(mat_new)
|
||||||
|
}
|
||||||
|
func GetRow(arr Arr, submat *Mat, row int) *Mat {
|
||||||
|
mat_new := C.cvGetRow(
|
||||||
|
unsafe.Pointer(arr),
|
||||||
|
(*C.CvMat)(submat),
|
||||||
|
C.int(row),
|
||||||
|
)
|
||||||
|
return (*Mat)(mat_new)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Selects column span of the input array: arr(:,start_col:end_col)
|
||||||
|
(end_col is not included into the span) */
|
||||||
|
func GetCols(arr Arr, submat *Mat, start_col, end_col int) *Mat {
|
||||||
|
mat_new := C.cvGetCols(
|
||||||
|
unsafe.Pointer(arr),
|
||||||
|
(*C.CvMat)(submat),
|
||||||
|
C.int(start_col),
|
||||||
|
C.int(end_col),
|
||||||
|
)
|
||||||
|
return (*Mat)(mat_new)
|
||||||
|
}
|
||||||
|
func GetCol(arr Arr, submat *Mat, col int) *Mat {
|
||||||
|
mat_new := C.cvGetCol(
|
||||||
|
unsafe.Pointer(arr),
|
||||||
|
(*C.CvMat)(submat),
|
||||||
|
C.int(col),
|
||||||
|
)
|
||||||
|
return (*Mat)(mat_new)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Select a diagonal of the input array.
|
||||||
|
(diag = 0 means the main diagonal, >0 means a diagonal above the main one,
|
||||||
|
<0 - below the main one).
|
||||||
|
The diagonal will be represented as a column (nx1 matrix). */
|
||||||
|
func GetDiag(arr Arr, submat *Mat, diag int) *Mat {
|
||||||
|
mat_new := C.cvGetDiag(
|
||||||
|
unsafe.Pointer(arr),
|
||||||
|
(*C.CvMat)(submat),
|
||||||
|
C.int(diag),
|
||||||
|
)
|
||||||
|
return (*Mat)(mat_new)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* low-level scalar <-> raw data conversion functions */
|
||||||
|
func ScalarToRawData(scalar *Scalar, data unsafe.Pointer, type_, extend_to_12 int) {
|
||||||
|
C.cvScalarToRawData(
|
||||||
|
(*C.CvScalar)(scalar),
|
||||||
|
data,
|
||||||
|
C.int(type_),
|
||||||
|
C.int(extend_to_12),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func RawDataToScalar(data unsafe.Pointer, type_ int , scalar *Scalar) {
|
||||||
|
C.cvRawDataToScalar(
|
||||||
|
data,
|
||||||
|
C.int(type_),
|
||||||
|
(*C.CvScalar)(scalar),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocates and initializes CvMatND header */
|
||||||
|
func CreateMatNDHeader(sizes []int, type_ int) *MatND {
|
||||||
|
dims := C.int(len(sizes))
|
||||||
|
sizes_c := make([]C.int, len(sizes))
|
||||||
|
for i := 0; i < len(sizes); i++ {
|
||||||
|
sizes_c[i] = C.int(sizes[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
mat := C.cvCreateMatNDHeader(
|
||||||
|
dims, (*C.int)(&sizes_c[0]), C.int(type_),
|
||||||
|
)
|
||||||
|
return (*MatND)(mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocates and initializes CvMatND header and allocates data */
|
||||||
|
func CreateMatND(sizes []int, type_ int) *MatND {
|
||||||
|
dims := C.int(len(sizes))
|
||||||
|
sizes_c := make([]C.int, len(sizes))
|
||||||
|
for i := 0; i < len(sizes); i++ {
|
||||||
|
sizes_c[i] = C.int(sizes[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
mat := C.cvCreateMatND(
|
||||||
|
dims, (*C.int)(&sizes_c[0]), C.int(type_),
|
||||||
|
)
|
||||||
|
return (*MatND)(mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initializes preallocated CvMatND header */
|
||||||
|
func (mat *MatND)InitMatNDHeader(sizes []int, type_ int, data unsafe.Pointer) {
|
||||||
|
dims := C.int(len(sizes))
|
||||||
|
sizes_c := make([]C.int, len(sizes))
|
||||||
|
for i := 0; i < len(sizes); i++ {
|
||||||
|
sizes_c[i] = C.int(sizes[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
C.cvInitMatNDHeader(
|
||||||
|
(*C.CvMatND)(mat),
|
||||||
|
dims, (*C.int)(&sizes_c[0]), C.int(type_),
|
||||||
|
data,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Releases CvMatND */
|
||||||
|
func (mat *MatND)Release() {
|
||||||
|
mat_c := (*C.CvMatND)(mat)
|
||||||
|
C.cvReleaseMatND(&mat_c)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creates a copy of CvMatND (except, may be, steps) */
|
||||||
|
func (mat *MatND)Clone() *MatND {
|
||||||
|
mat_c := (*C.CvMatND)(mat)
|
||||||
|
mat_ret := C.cvCloneMatND(mat_c)
|
||||||
|
return (*MatND)(mat_ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocates and initializes CvSparseMat header and allocates data */
|
||||||
|
func CreateSparseMat(sizes []int, type_ int) *SparseMat {
|
||||||
|
dims := C.int(len(sizes))
|
||||||
|
sizes_c := make([]C.int, len(sizes))
|
||||||
|
for i := 0; i < len(sizes); i++ {
|
||||||
|
sizes_c[i] = C.int(sizes[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
mat := C.cvCreateSparseMat(
|
||||||
|
dims, (*C.int)(&sizes_c[0]), C.int(type_),
|
||||||
|
)
|
||||||
|
return (*SparseMat)(mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Releases CvSparseMat */
|
||||||
|
func (mat *SparseMat)Release() {
|
||||||
|
mat_c := (*C.CvSparseMat)(mat)
|
||||||
|
C.cvReleaseSparseMat(&mat_c)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creates a copy of CvSparseMat (except, may be, zero items) */
|
||||||
|
func (mat *SparseMat)Clone() *SparseMat {
|
||||||
|
mat_c := (*C.CvSparseMat)(mat)
|
||||||
|
mat_ret := C.cvCloneSparseMat(mat_c)
|
||||||
|
return (*SparseMat)(mat_ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initializes sparse array iterator
|
||||||
|
(returns the first node or NULL if the array is empty) */
|
||||||
|
func (mat *SparseMat)InitSparseMatIterator(iter *SparseMatIterator) *SparseNode {
|
||||||
|
mat_c := (*C.CvSparseMat)(mat)
|
||||||
|
node := C.cvInitSparseMatIterator(mat_c, (*C.CvSparseMatIterator)(iter))
|
||||||
|
return (*SparseNode)(node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns next sparse array node (or NULL if there is no more nodes)
|
||||||
|
func (iter *SparseMatIterator)Next() *SparseNode {
|
||||||
|
node := C.cvGetNextSparseNode((*C.CvSparseMatIterator)(iter))
|
||||||
|
return (*SparseNode)(node)
|
||||||
|
}
|
||||||
|
|
||||||
|
/******** matrix iterator: used for n-ary operations on dense arrays *********/
|
||||||
|
|
||||||
|
// P290
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
}
|
||||||
|
func GetSizeHeight(img *IplImage) int {
|
||||||
|
size := C.cvGetSize(unsafe.Pointer(img))
|
||||||
|
w := int(size.height)
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
func GetSize(img *IplImage) Size {
|
||||||
|
sz := C.cvGetSize(unsafe.Pointer(img))
|
||||||
|
return Size{ int(sz.width), int(sz.height) }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copies source array to destination array */
|
||||||
|
func Copy(src, dst, mask *IplImage) {
|
||||||
|
C.cvCopy(unsafe.Pointer(src), unsafe.Pointer(dst), unsafe.Pointer(mask))
|
||||||
|
}
|
||||||
|
//CVAPI(void) cvCopy( const CvArr* src, CvArr* dst,
|
||||||
|
// const CvArr* mask CV_DEFAULT(NULL) );
|
||||||
|
|
||||||
|
/* Clears all the array elements (sets them to 0) */
|
||||||
|
func Zero(img *IplImage) {
|
||||||
|
C.cvSetZero(unsafe.Pointer(img))
|
||||||
|
}
|
||||||
|
//CVAPI(void) cvSetZero( CvArr* arr );
|
||||||
|
//#define cvZero cvSetZero
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Arithmetic, logic and comparison operations *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/* dst(idx) = ~src(idx) */
|
||||||
|
func Not(src, dst *IplImage) {
|
||||||
|
C.cvNot(unsafe.Pointer(src), unsafe.Pointer(dst))
|
||||||
|
}
|
||||||
|
//CVAPI(void) cvNot( const CvArr* src, CvArr* dst );
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Math operations *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Matrix operations *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Array Statistics *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Discrete Linear Transforms and Related Functions *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Dynamic data structures *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Drawing *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
/* Draws 4-connected, 8-connected or antialiased line segment connecting two points */
|
||||||
|
//color Scalar,
|
||||||
|
func Line(image *IplImage, pt1, pt2 Point, color Scalar, thickness, line_type, shift int) {
|
||||||
|
C.cvLine(
|
||||||
|
unsafe.Pointer(image),
|
||||||
|
C.cvPoint(C.int(pt1.X), C.int(pt1.Y)),
|
||||||
|
C.cvPoint(C.int(pt2.X), C.int(pt2.Y)),
|
||||||
|
(C.CvScalar)(color),
|
||||||
|
C.int(thickness), C.int(line_type), C.int(shift),
|
||||||
|
)
|
||||||
|
//Scalar
|
||||||
|
}
|
||||||
|
|
||||||
|
//CVAPI(void) cvLine( CvArr* img, CvPoint pt1, CvPoint pt2,
|
||||||
|
// CvScalar color, int thickness CV_DEFAULT(1),
|
||||||
|
// int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* System functions *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Data Persistence *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
10
opencv/cxcore_test.go
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
package opencv
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLoadImage2(t *testing.T) {
|
||||||
|
// t.Errorf("aaa")
|
||||||
|
}
|
||||||
|
|
||||||
680
opencv/cxtype.go
Normal file
|
|
@ -0,0 +1,680 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package opencv
|
||||||
|
|
||||||
|
/*
|
||||||
|
#cgo linux pkg-config: opencv
|
||||||
|
#cgo darwin pkg-config: opencv
|
||||||
|
#cgo windows LDFLAGS: -lopencv_core242.dll -lopencv_imgproc242.dll -lopencv_photo242.dll -lopencv_highgui242.dll -lstdc++
|
||||||
|
|
||||||
|
#include "opencv.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// version
|
||||||
|
// const char* CV_VERSION_ = CV_VERSION;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// IplImage
|
||||||
|
static int IPL_IMAGE_MAGIC_VAL_() {
|
||||||
|
return IPL_IMAGE_MAGIC_VAL;
|
||||||
|
}
|
||||||
|
static const char* CV_TYPE_NAME_IMAGE_() {
|
||||||
|
return CV_TYPE_NAME_IMAGE;
|
||||||
|
}
|
||||||
|
static int CV_IS_IMAGE_HDR_(void* img) {
|
||||||
|
return CV_IS_IMAGE_HDR(img);
|
||||||
|
}
|
||||||
|
static int CV_IS_IMAGE_(void* img) {
|
||||||
|
return CV_IS_IMAGE(img);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// type filed is go keyword
|
||||||
|
static int myGetMatType(const CvMat* mat) {
|
||||||
|
return mat->type;
|
||||||
|
}
|
||||||
|
static int myGetMatNDType(const CvMatND* mat) {
|
||||||
|
return mat->type;
|
||||||
|
}
|
||||||
|
static int myGetSparseMatType(const CvSparseMat* mat) {
|
||||||
|
return mat->type;
|
||||||
|
}
|
||||||
|
static int myGetTermCriteriaType(const CvTermCriteria* x) {
|
||||||
|
return x->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// cvver.h
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_MAJOR_VERSION = int(C.CV_MAJOR_VERSION)
|
||||||
|
CV_MINOR_VERSION = int(C.CV_MINOR_VERSION)
|
||||||
|
CV_SUBMINOR_VERSION = int(C.CV_SUBMINOR_VERSION)
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
//CV_VERSION = C.GoString(C.CV_VERSION_)
|
||||||
|
)
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// cxerror.h
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_StsOk = C.CV_StsOk
|
||||||
|
CV_StsBackTrace = C.CV_StsBackTrace
|
||||||
|
CV_StsError = C.CV_StsError
|
||||||
|
CV_StsInternal = C.CV_StsInternal
|
||||||
|
CV_StsNoMem = C.CV_StsNoMem
|
||||||
|
CV_StsBadArg = C.CV_StsBadArg
|
||||||
|
CV_StsBadFunc = C.CV_StsBadFunc
|
||||||
|
CV_StsNoConv = C.CV_StsNoConv
|
||||||
|
CV_StsAutoTrace = C.CV_StsAutoTrace
|
||||||
|
CV_HeaderIsNull = C.CV_HeaderIsNull
|
||||||
|
CV_BadImageSize = C.CV_BadImageSize
|
||||||
|
CV_BadOffset = C.CV_BadOffset
|
||||||
|
CV_BadDataPtr = C.CV_BadDataPtr
|
||||||
|
CV_BadStep = C.CV_BadStep
|
||||||
|
CV_BadModelOrChSeq = C.CV_BadModelOrChSeq
|
||||||
|
CV_BadNumChannels = C.CV_BadNumChannels
|
||||||
|
CV_BadNumChannel1U = C.CV_BadNumChannel1U
|
||||||
|
CV_BadDepth = C.CV_BadDepth
|
||||||
|
CV_BadAlphaChannel = C.CV_BadAlphaChannel
|
||||||
|
CV_BadOrder = C.CV_BadOrder
|
||||||
|
CV_BadOrigin = C.CV_BadOrigin
|
||||||
|
CV_BadAlign = C.CV_BadAlign
|
||||||
|
CV_BadCallBack = C.CV_BadCallBack
|
||||||
|
CV_BadTileSize = C.CV_BadTileSize
|
||||||
|
CV_BadCOI = C.CV_BadCOI
|
||||||
|
CV_BadROISize = C.CV_BadROISize
|
||||||
|
CV_MaskIsTiled = C.CV_MaskIsTiled
|
||||||
|
CV_StsNullPtr = C.CV_StsNullPtr
|
||||||
|
CV_StsVecLengthErr = C.CV_StsVecLengthErr
|
||||||
|
CV_StsFilterStructContentErr = C.CV_StsFilterStructContentErr
|
||||||
|
CV_StsKernelStructContentErr = C.CV_StsKernelStructContentErr
|
||||||
|
CV_StsFilterOffsetErr = C.CV_StsFilterOffsetErr
|
||||||
|
CV_StsBadSize = C.CV_StsBadSize
|
||||||
|
CV_StsDivByZero = C.CV_StsDivByZero
|
||||||
|
CV_StsInplaceNotSupported = C.CV_StsInplaceNotSupported
|
||||||
|
CV_StsObjectNotFound = C.CV_StsObjectNotFound
|
||||||
|
CV_StsUnmatchedFormats = C.CV_StsUnmatchedFormats
|
||||||
|
CV_StsBadFlag = C.CV_StsBadFlag
|
||||||
|
CV_StsBadPoint = C.CV_StsBadPoint
|
||||||
|
CV_StsBadMask = C.CV_StsBadMask
|
||||||
|
CV_StsUnmatchedSizes = C.CV_StsUnmatchedSizes
|
||||||
|
CV_StsUnsupportedFormat = C.CV_StsUnsupportedFormat
|
||||||
|
CV_StsOutOfRange = C.CV_StsOutOfRange
|
||||||
|
CV_StsParseError = C.CV_StsParseError
|
||||||
|
CV_StsNotImplemented = C.CV_StsNotImplemented
|
||||||
|
CV_StsBadMemBlock = C.CV_StsBadMemBlock
|
||||||
|
CV_StsAssert = C.CV_StsAssert
|
||||||
|
//CV_GpuNotSupported= C.CV_GpuNotSupported
|
||||||
|
//CV_GpuApiCallError= C.CV_GpuApiCallError
|
||||||
|
//CV_GpuNppCallError= C.CV_GpuNppCallError
|
||||||
|
)
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// cxtypes.h
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
type Arr unsafe.Pointer
|
||||||
|
|
||||||
|
/*****************************************************************************\
|
||||||
|
* Common macros and inline functions *
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_PI = 3.1415926535897932384626433832795
|
||||||
|
CV_LOG2 = 0.69314718055994530941723212145818
|
||||||
|
)
|
||||||
|
|
||||||
|
func Round(value float64) int {
|
||||||
|
rv := C.cvRound(C.double(value))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
func Floor(value float64) int {
|
||||||
|
rv := C.cvFloor(C.double(value))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
func Ceil(value float64) int {
|
||||||
|
rv := C.cvCeil(C.double(value))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsNaN(value float64) int {
|
||||||
|
rv := C.cvIsNaN(C.double(value))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
func IsInf(value float64) int {
|
||||||
|
rv := C.cvIsInf(C.double(value))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************** Random number generation *******************/
|
||||||
|
|
||||||
|
type RNG C.CvRNG
|
||||||
|
|
||||||
|
func NewRNG(seed int64) RNG {
|
||||||
|
rv := C.cvRNG(C.int64(seed))
|
||||||
|
return RNG(rv)
|
||||||
|
}
|
||||||
|
func (rng *RNG) RandInt() uint32 {
|
||||||
|
rv := C.cvRandInt((*C.CvRNG)(rng))
|
||||||
|
return uint32(rv)
|
||||||
|
}
|
||||||
|
func (rng *RNG) RandReal() float64 {
|
||||||
|
rv := C.cvRandReal((*C.CvRNG)(rng))
|
||||||
|
return float64(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************\
|
||||||
|
* Image type (IplImage) *
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following definitions (until #endif)
|
||||||
|
* is an extract from IPL headers.
|
||||||
|
* Copyright (c) 1995 Intel Corporation.
|
||||||
|
*/
|
||||||
|
const (
|
||||||
|
IPL_DEPTH_SIGN = C.IPL_DEPTH_SIGN
|
||||||
|
|
||||||
|
IPL_DEPTH_1U = C.IPL_DEPTH_1U
|
||||||
|
IPL_DEPTH_8U = C.IPL_DEPTH_8U
|
||||||
|
IPL_DEPTH_16U = C.IPL_DEPTH_16U
|
||||||
|
IPL_DEPTH_32F = C.IPL_DEPTH_32F
|
||||||
|
|
||||||
|
IPL_DEPTH_8S = C.IPL_DEPTH_8S
|
||||||
|
IPL_DEPTH_16S = C.IPL_DEPTH_16S
|
||||||
|
IPL_DEPTH_32S = C.IPL_DEPTH_32S
|
||||||
|
|
||||||
|
IPL_DATA_ORDER_PIXEL = C.IPL_DATA_ORDER_PIXEL
|
||||||
|
IPL_DATA_ORDER_PLANE = C.IPL_DATA_ORDER_PLANE
|
||||||
|
|
||||||
|
IPL_ORIGIN_TL = C.IPL_ORIGIN_TL
|
||||||
|
IPL_ORIGIN_BL = C.IPL_ORIGIN_BL
|
||||||
|
|
||||||
|
IPL_ALIGN_4BYTES = C.IPL_ALIGN_4BYTES
|
||||||
|
IPL_ALIGN_8BYTES = C.IPL_ALIGN_8BYTES
|
||||||
|
IPL_ALIGN_16BYTES = C.IPL_ALIGN_16BYTES
|
||||||
|
IPL_ALIGN_32BYTES = C.IPL_ALIGN_32BYTES
|
||||||
|
|
||||||
|
IPL_ALIGN_DWORD = C.IPL_ALIGN_DWORD
|
||||||
|
IPL_ALIGN_QWORD = C.IPL_ALIGN_QWORD
|
||||||
|
|
||||||
|
IPL_BORDER_CONSTANT = C.IPL_BORDER_CONSTANT
|
||||||
|
IPL_BORDER_REPLICATE = C.IPL_BORDER_REPLICATE
|
||||||
|
IPL_BORDER_REFLECT = C.IPL_BORDER_REFLECT
|
||||||
|
IPL_BORDER_WRAP = C.IPL_BORDER_WRAP
|
||||||
|
)
|
||||||
|
|
||||||
|
type IplImage C.IplImage
|
||||||
|
|
||||||
|
// normal fields
|
||||||
|
func (img *IplImage)Channels() int {
|
||||||
|
return int(img.nChannels)
|
||||||
|
}
|
||||||
|
func (img *IplImage)Depth() int {
|
||||||
|
return int(img.depth)
|
||||||
|
}
|
||||||
|
func (img *IplImage)Origin() int {
|
||||||
|
return int(img.origin)
|
||||||
|
}
|
||||||
|
func (img *IplImage)Width() int {
|
||||||
|
return int(img.width)
|
||||||
|
}
|
||||||
|
func (img *IplImage)Height() int {
|
||||||
|
return int(img.height)
|
||||||
|
}
|
||||||
|
func (img *IplImage)WidthStep() int {
|
||||||
|
return int(img.widthStep)
|
||||||
|
}
|
||||||
|
func (img *IplImage)ImageSize() int {
|
||||||
|
return int(img.imageSize)
|
||||||
|
}
|
||||||
|
func (img *IplImage)ImageData() unsafe.Pointer {
|
||||||
|
return unsafe.Pointer(img.imageData)
|
||||||
|
}
|
||||||
|
|
||||||
|
type IplROI C.IplROI
|
||||||
|
|
||||||
|
func (roi *IplROI)Init(coi, xOffset, yOffset, width, height int) {
|
||||||
|
roi_c := (*C.IplROI)(roi)
|
||||||
|
roi_c.coi = C.int(coi)
|
||||||
|
roi_c.xOffset = C.int(xOffset)
|
||||||
|
roi_c.yOffset = C.int(yOffset)
|
||||||
|
roi_c.width = C.int(width)
|
||||||
|
roi_c.height = C.int(height)
|
||||||
|
}
|
||||||
|
func (roi *IplROI)Coi() int {
|
||||||
|
roi_c := (*C.IplROI)(roi)
|
||||||
|
return int(roi_c.coi)
|
||||||
|
}
|
||||||
|
func (roi *IplROI)XOffset() int {
|
||||||
|
roi_c := (*C.IplROI)(roi)
|
||||||
|
return int(roi_c.xOffset)
|
||||||
|
}
|
||||||
|
func (roi *IplROI)YOffset() int {
|
||||||
|
roi_c := (*C.IplROI)(roi)
|
||||||
|
return int(roi_c.yOffset)
|
||||||
|
}
|
||||||
|
func (roi *IplROI)Width() int {
|
||||||
|
roi_c := (*C.IplROI)(roi)
|
||||||
|
return int(roi_c.width)
|
||||||
|
}
|
||||||
|
func (roi *IplROI)Height() int {
|
||||||
|
roi_c := (*C.IplROI)(roi)
|
||||||
|
return int(roi_c.height)
|
||||||
|
}
|
||||||
|
|
||||||
|
type IplConvKernel C.IplConvKernel
|
||||||
|
type IplConvKernelFP C.IplConvKernelFP
|
||||||
|
|
||||||
|
const (
|
||||||
|
IPL_IMAGE_HEADER = C.IPL_IMAGE_HEADER
|
||||||
|
IPL_IMAGE_DATA = C.IPL_IMAGE_DATA
|
||||||
|
IPL_IMAGE_ROI = C.IPL_IMAGE_ROI
|
||||||
|
)
|
||||||
|
|
||||||
|
/* extra border mode */
|
||||||
|
var (
|
||||||
|
IPL_IMAGE_MAGIC_VAL = C.IPL_IMAGE_MAGIC_VAL_()
|
||||||
|
CV_TYPE_NAME_IMAGE = C.CV_TYPE_NAME_IMAGE_()
|
||||||
|
)
|
||||||
|
|
||||||
|
func CV_IS_IMAGE_HDR(img unsafe.Pointer) bool {
|
||||||
|
rv := C.CV_IS_IMAGE_HDR_(img)
|
||||||
|
return (int(rv) != 0)
|
||||||
|
}
|
||||||
|
func CV_IS_IMAGE(img unsafe.Pointer) bool {
|
||||||
|
rv := C.CV_IS_IMAGE_(img)
|
||||||
|
return (int(rv) != 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
IPL_DEPTH_64F = int(C.IPL_DEPTH_64F)
|
||||||
|
)
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Matrix type (CvMat) *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
type Mat C.CvMat
|
||||||
|
|
||||||
|
func (mat *Mat)Type() int {
|
||||||
|
return int(C.myGetMatType((*C.CvMat)(mat)))
|
||||||
|
}
|
||||||
|
func (mat *Mat)Step() int {
|
||||||
|
return int(mat.step)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mat *Mat)Rows() int {
|
||||||
|
return int(mat.rows)
|
||||||
|
}
|
||||||
|
func (mat *Mat)Cols() int {
|
||||||
|
return int(mat.cols)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CV_IS_MAT_HDR(mat interface{}) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
func CV_IS_MAT(mat interface{}) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
func CV_IS_MASK_ARR() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
func CV_ARE_TYPE_EQ() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Mat)Init(rows, cols int, type_ int, data unsafe.Pointer) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (m *Mat)Get(row, col int) float64 {
|
||||||
|
rv := C.cvmGet((*C.CvMat)(m), C.int(row), C.int(col))
|
||||||
|
return float64(rv)
|
||||||
|
}
|
||||||
|
func (m *Mat)Set(row, col int, value float64) {
|
||||||
|
C.cvmSet((*C.CvMat)(m), C.int(row), C.int(col), C.double(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
func IplDepth(type_ int) int {
|
||||||
|
rv := C.cvIplDepth(C.int(type_))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Multi-dimensional dense array (CvMatND) *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_MATND_MAGIC_VAL = C.CV_MATND_MAGIC_VAL
|
||||||
|
CV_TYPE_NAME_MATND = C.CV_TYPE_NAME_MATND
|
||||||
|
|
||||||
|
CV_MAX_DIM = C.CV_MAX_DIM
|
||||||
|
CV_MAX_DIM_HEAP = C.CV_MAX_DIM_HEAP
|
||||||
|
)
|
||||||
|
|
||||||
|
type MatND C.CvMatND
|
||||||
|
|
||||||
|
func (m *MatND)Type() int {
|
||||||
|
rv := C.myGetMatNDType((*C.CvMatND)(m))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
func (m *MatND)Dims() int {
|
||||||
|
rv := m.dims
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Multi-dimensional sparse array (CvSparseMat) *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_SPARSE_MAT_MAGIC_VAL = C.CV_SPARSE_MAT_MAGIC_VAL
|
||||||
|
CV_TYPE_NAME_SPARSE_MAT = C.CV_TYPE_NAME_SPARSE_MAT
|
||||||
|
)
|
||||||
|
|
||||||
|
type SparseMat C.CvSparseMat
|
||||||
|
|
||||||
|
func (m *SparseMat)Type() int {
|
||||||
|
rv := C.myGetSparseMatType((*C.CvSparseMat)(m))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
func (m *SparseMat)Dims() int {
|
||||||
|
rv := m.dims
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************** iteration through a sparse array *****************/
|
||||||
|
|
||||||
|
type SparseNode C.CvSparseNode
|
||||||
|
|
||||||
|
func (node *SparseNode)HashVal() uint32 {
|
||||||
|
rv := node.hashval
|
||||||
|
return uint32(rv)
|
||||||
|
}
|
||||||
|
func (node *SparseNode)Next() *SparseNode {
|
||||||
|
rv := node.next
|
||||||
|
return (*SparseNode)(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
type SparseMatIterator C.CvSparseMatIterator
|
||||||
|
|
||||||
|
func (node *SparseMatIterator)Mat() *SparseMat {
|
||||||
|
rv := node.mat
|
||||||
|
return (*SparseMat)(rv)
|
||||||
|
}
|
||||||
|
func (node *SparseMatIterator)Node() *SparseNode {
|
||||||
|
rv := node.node
|
||||||
|
return (*SparseNode)(rv)
|
||||||
|
}
|
||||||
|
func (node *SparseMatIterator)CurIdx() int {
|
||||||
|
rv := node.curidx
|
||||||
|
return (int)(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Histogram *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
type HistType C.CvHistType
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_HIST_MAGIC_VAL = C.CV_HIST_MAGIC_VAL
|
||||||
|
CV_HIST_UNIFORM_FLAG = C.CV_HIST_UNIFORM_FLAG
|
||||||
|
|
||||||
|
/* indicates whether bin ranges are set already or not */
|
||||||
|
CV_HIST_RANGES_FLAG = C.CV_HIST_RANGES_FLAG
|
||||||
|
|
||||||
|
CV_HIST_ARRAY = C.CV_HIST_ARRAY
|
||||||
|
CV_HIST_SPARSE = C.CV_HIST_SPARSE
|
||||||
|
CV_HIST_TREE = C.CV_HIST_TREE
|
||||||
|
|
||||||
|
/* should be used as a parameter only,
|
||||||
|
it turns to CV_HIST_UNIFORM_FLAG of hist->type */
|
||||||
|
CV_HIST_UNIFORM = C.CV_HIST_UNIFORM
|
||||||
|
)
|
||||||
|
|
||||||
|
type Histogram C.CvHistogram
|
||||||
|
|
||||||
|
func CV_IS_HIST() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
func CV_IS_UNIFORM_HIST() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
func CV_IS_SPARSE_HIST() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
func CV_HIST_HAS_RANGES() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Other supplementary data type definitions *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
/*************************************** CvRect *****************************************/
|
||||||
|
|
||||||
|
type Rect C.CvRect
|
||||||
|
|
||||||
|
func (r *Rect)Init(x, y, w, h int) {
|
||||||
|
r.x = C.int(x)
|
||||||
|
r.y = C.int(y)
|
||||||
|
r.width = C.int(w)
|
||||||
|
r.height = C.int(h)
|
||||||
|
}
|
||||||
|
func (r *Rect)X() int {
|
||||||
|
r_c := (*C.CvRect)(r)
|
||||||
|
return int(r_c.x)
|
||||||
|
}
|
||||||
|
func (r *Rect)Y() int {
|
||||||
|
r_c := (*C.CvRect)(r)
|
||||||
|
return int(r_c.y)
|
||||||
|
}
|
||||||
|
func (r *Rect)Width() int {
|
||||||
|
r_c := (*C.CvRect)(r)
|
||||||
|
return int(r_c.width)
|
||||||
|
}
|
||||||
|
func (r *Rect)Height() int {
|
||||||
|
r_c := (*C.CvRect)(r)
|
||||||
|
return int(r_c.height)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Rect)ToROI(coi int) IplROI {
|
||||||
|
r_c := (*C.CvRect)(r)
|
||||||
|
return (IplROI)(C.cvRectToROI(*r_c, C.int(coi)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (roi *IplROI)ToRect() Rect {
|
||||||
|
r := C.cvRect(
|
||||||
|
C.int(roi.XOffset()),
|
||||||
|
C.int(roi.YOffset()),
|
||||||
|
C.int(roi.Width()),
|
||||||
|
C.int(roi.Height()),
|
||||||
|
)
|
||||||
|
return Rect(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************** CvTermCriteria *************************************/
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_TERMCRIT_ITER = C.CV_TERMCRIT_ITER
|
||||||
|
CV_TERMCRIT_NUMBER = C.CV_TERMCRIT_NUMBER
|
||||||
|
CV_TERMCRIT_EPS = C.CV_TERMCRIT_EPS
|
||||||
|
)
|
||||||
|
|
||||||
|
type TermCriteria C.CvTermCriteria
|
||||||
|
|
||||||
|
func (x *TermCriteria)Init(type_, max_iter int, epsilon float64) {
|
||||||
|
rv := C.cvTermCriteria(C.int(type_), C.int(max_iter), C.double(epsilon))
|
||||||
|
(*x) = (TermCriteria)(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *TermCriteria)Type() int {
|
||||||
|
rv := C.myGetTermCriteriaType((*C.CvTermCriteria)(x))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
func (x *TermCriteria)MaxIter() int {
|
||||||
|
rv := x.max_iter
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
func (x *TermCriteria)Epsilon() float64 {
|
||||||
|
rv := x.epsilon
|
||||||
|
return float64(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************* CvPoint and variants ***********************************/
|
||||||
|
|
||||||
|
type Point struct {
|
||||||
|
X int
|
||||||
|
Y int
|
||||||
|
}
|
||||||
|
|
||||||
|
type Point2D32f struct {
|
||||||
|
X float32
|
||||||
|
Y float32
|
||||||
|
}
|
||||||
|
type Point3D32f struct {
|
||||||
|
X float32
|
||||||
|
Y float32
|
||||||
|
Z float32
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type Point2D64f struct {
|
||||||
|
X float64
|
||||||
|
Y float64
|
||||||
|
}
|
||||||
|
type Point3D64f struct {
|
||||||
|
X float64
|
||||||
|
Y float64
|
||||||
|
Z float64
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************** CvSize's & CvBox **************************************/
|
||||||
|
|
||||||
|
type Size struct {
|
||||||
|
Width int
|
||||||
|
Height int
|
||||||
|
}
|
||||||
|
|
||||||
|
type Size2D32f struct {
|
||||||
|
Width float32
|
||||||
|
Height float32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Box2D struct {
|
||||||
|
center Point2D32f
|
||||||
|
size Size2D32f
|
||||||
|
angle float32
|
||||||
|
}
|
||||||
|
|
||||||
|
type LineIterator C.CvLineIterator
|
||||||
|
|
||||||
|
/************************************* CvSlice ******************************************/
|
||||||
|
|
||||||
|
type Slice C.CvSlice
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_WHOLE_SEQ_END_INDEX = C.CV_WHOLE_SEQ_END_INDEX
|
||||||
|
)
|
||||||
|
|
||||||
|
/************************************* CvScalar *****************************************/
|
||||||
|
|
||||||
|
type Scalar C.CvScalar
|
||||||
|
|
||||||
|
func ScalarAll(val0 float64) Scalar {
|
||||||
|
rv := C.cvScalarAll(C.double(val0))
|
||||||
|
return (Scalar)(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Dynamic Data structures *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
/******************************** Memory storage ****************************************/
|
||||||
|
|
||||||
|
type MemBlock C.CvMemBlock
|
||||||
|
type MemStorage C.CvMemStorage
|
||||||
|
type MemStoragePos C.CvMemStoragePos
|
||||||
|
|
||||||
|
/*********************************** Sequence *******************************************/
|
||||||
|
|
||||||
|
type SeqBlock C.CvSeqBlock
|
||||||
|
type Seq C.CvSeq
|
||||||
|
|
||||||
|
/*************************************** Set ********************************************/
|
||||||
|
|
||||||
|
type Set C.CvSet
|
||||||
|
|
||||||
|
/************************************* Graph ********************************************/
|
||||||
|
|
||||||
|
type GraphEdge C.CvGraphEdge
|
||||||
|
type GraphVtx C.CvGraphVtx
|
||||||
|
|
||||||
|
type GraphVtx2D C.CvGraphVtx2D
|
||||||
|
type Graph C.CvGraph
|
||||||
|
|
||||||
|
/*********************************** Chain/Countour *************************************/
|
||||||
|
|
||||||
|
type Chain C.CvChain
|
||||||
|
type Contour C.CvContour
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Sequence types *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
/* Sequence writer & reader */
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
type SeqWriter C.CvSeqWriter
|
||||||
|
type SeqReader C.CvSeqReader
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
/* Operations on sequences */
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************************\
|
||||||
|
* Data structures for persistence (a.k.a serialization) functionality *
|
||||||
|
\****************************************************************************************/
|
||||||
|
|
||||||
|
/* "black box" file storage */
|
||||||
|
type FileStorage C.CvFileStorage
|
||||||
|
|
||||||
|
/* Storage flags: */
|
||||||
|
const (
|
||||||
|
CV_STORAGE_READ = C.CV_STORAGE_READ
|
||||||
|
CV_STORAGE_WRITE = C.CV_STORAGE_WRITE
|
||||||
|
CV_STORAGE_WRITE_TEXT = C.CV_STORAGE_WRITE_TEXT
|
||||||
|
CV_STORAGE_WRITE_BINARY = C.CV_STORAGE_WRITE_BINARY
|
||||||
|
CV_STORAGE_APPEND = C.CV_STORAGE_APPEND
|
||||||
|
)
|
||||||
|
|
||||||
|
type AttrList C.CvAttrList
|
||||||
|
|
||||||
|
/*****************************************************************************\
|
||||||
|
* --- END --- *
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
7
opencv/doc.go
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Bindings for Intel's OpenCV computer vision library.
|
||||||
|
package opencv
|
||||||
|
|
||||||
597
opencv/highgui.go
Normal file
|
|
@ -0,0 +1,597 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package opencv
|
||||||
|
|
||||||
|
//#include "opencv.h"
|
||||||
|
//#cgo linux pkg-config: opencv
|
||||||
|
//#cgo darwin pkg-config: opencv
|
||||||
|
//#cgo windows LDFLAGS: -lopencv_core242.dll -lopencv_imgproc242.dll -lopencv_photo242.dll -lopencv_highgui242.dll -lstdc++
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
|
_ "fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************\
|
||||||
|
* Basic GUI functions *
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
/* this function is used to set some external parameters in case of X Window */
|
||||||
|
func initSystem(args []string) int {
|
||||||
|
argc := C.int(len(args))
|
||||||
|
argv := make([]*C.char, len(args))
|
||||||
|
for i := 0; i < len(args); i++ {
|
||||||
|
argv[i] = C.CString(args[i])
|
||||||
|
}
|
||||||
|
rv := C.cvInitSystem(argc, (**C.char)(unsafe.Pointer(&argv)))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func StartWindowThread() int {
|
||||||
|
return int(C.cvStartWindowThread())
|
||||||
|
}
|
||||||
|
|
||||||
|
/* wait for key event infinitely (delay<=0) or for "delay" milliseconds */
|
||||||
|
func WaitKey(delay int) int {
|
||||||
|
key := C.cvWaitKey(C.int(delay))
|
||||||
|
return int(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Window wrapper for go
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// mouse callback
|
||||||
|
type MouseFunc interface{}
|
||||||
|
type MouseFuncA func(event, x, y, flags int)
|
||||||
|
type MouseFuncB func(event, x, y, flags int, param ...interface{})
|
||||||
|
|
||||||
|
// trackbar callback
|
||||||
|
type TrackbarFunc interface{}
|
||||||
|
type TrackbarFuncA func(pos int)
|
||||||
|
type TrackbarFuncB func(pos int, param ...interface{})
|
||||||
|
|
||||||
|
// named window
|
||||||
|
type Window struct {
|
||||||
|
name string
|
||||||
|
name_c *C.char
|
||||||
|
flags C.int
|
||||||
|
|
||||||
|
mouseHandle MouseFunc
|
||||||
|
param []interface{}
|
||||||
|
|
||||||
|
trackbarHandle map[string]TrackbarFunc
|
||||||
|
trackbarMax map[string]int
|
||||||
|
trackbarVal map[string]int
|
||||||
|
trackbarName map[string](*C.char)
|
||||||
|
trackbarParam map[string]([]interface{})
|
||||||
|
|
||||||
|
image *IplImage
|
||||||
|
refCount int
|
||||||
|
}
|
||||||
|
|
||||||
|
// window list
|
||||||
|
var allWindows = make(map[string]*Window, 1000)
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// window: create
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_WINDOW_AUTOSIZE = C.CV_WINDOW_AUTOSIZE
|
||||||
|
)
|
||||||
|
|
||||||
|
/* create window */
|
||||||
|
func NewWindow(name string, flags ...int) *Window {
|
||||||
|
win_flags := C.int(CV_WINDOW_AUTOSIZE)
|
||||||
|
if len(flags) > 0 {
|
||||||
|
win_flags = C.int(flags[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
win := &Window{
|
||||||
|
name:name,
|
||||||
|
name_c:C.CString(name),
|
||||||
|
flags:win_flags,
|
||||||
|
|
||||||
|
trackbarHandle:make(map[string]TrackbarFunc, 50),
|
||||||
|
trackbarMax:make(map[string]int, 50),
|
||||||
|
trackbarVal:make(map[string]int, 50),
|
||||||
|
trackbarName:make(map[string](*C.char), 50),
|
||||||
|
trackbarParam:make(map[string]([]interface{}), 50),
|
||||||
|
}
|
||||||
|
C.cvNamedWindow(win.name_c, win.flags)
|
||||||
|
C.GoOpenCV_SetMouseCallback(win.name_c)
|
||||||
|
|
||||||
|
allWindows[win.name] = win
|
||||||
|
return win
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------- YV ---------
|
||||||
|
const (
|
||||||
|
CV_WND_PROP_FULLSCREEN = int(C.CV_WND_PROP_FULLSCREEN)
|
||||||
|
CV_WND_PROP_AUTOSIZE = int(C.CV_WND_PROP_AUTOSIZE)
|
||||||
|
CV_WINDOW_NORMAL = int(C.CV_WINDOW_NORMAL)
|
||||||
|
CV_WINDOW_FULLSCREEN = int(C.CV_WINDOW_FULLSCREEN)
|
||||||
|
)
|
||||||
|
/* Set and Get Property of the window */
|
||||||
|
func (win *Window)SetProperty(prop_id int, value float64) {
|
||||||
|
C.cvSetWindowProperty(win.name_c, C.int(prop_id), C.double(value))
|
||||||
|
}
|
||||||
|
func (win *Window)GetProperty(prop_id int) float64 {
|
||||||
|
rv := C.cvGetWindowProperty(win.name_c, C.int(prop_id))
|
||||||
|
return float64(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* display image within window (highgui windows remember their content) */
|
||||||
|
func (win *Window)ShowImage(image *IplImage) {
|
||||||
|
win.image = image
|
||||||
|
C.cvShowImage(win.name_c, unsafe.Pointer(image))
|
||||||
|
}
|
||||||
|
|
||||||
|
/* resize/move window */
|
||||||
|
func (win *Window)Resize(width, height int) {
|
||||||
|
C.cvResizeWindow(win.name_c, C.int(width), C.int(height))
|
||||||
|
}
|
||||||
|
func (win *Window)Move(x, y int) {
|
||||||
|
C.cvMoveWindow(win.name_c, C.int(x), C.int(y))
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get native window handle (HWND in case of Win32 and Widget in case of X Window) */
|
||||||
|
func (win *Window)GetHandle() unsafe.Pointer {
|
||||||
|
p := C.cvGetWindowHandle(win.name_c)
|
||||||
|
return unsafe.Pointer(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get name of highgui window given its native handle */
|
||||||
|
func (win *Window)GetWindowName() string {
|
||||||
|
return win.name
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// window: track bar
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/* create trackbar and display it on top of given window, set callback */
|
||||||
|
func (win *Window)CreateTrackbar(name string,
|
||||||
|
value, count int,
|
||||||
|
on_changed TrackbarFunc, param ...interface{}) bool {
|
||||||
|
|
||||||
|
bar_name := C.CString(name)
|
||||||
|
|
||||||
|
switch f := on_changed.(type) {
|
||||||
|
case TrackbarFuncA:
|
||||||
|
win.trackbarHandle[name] = TrackbarFunc(f)
|
||||||
|
case TrackbarFuncB:
|
||||||
|
win.trackbarHandle[name] = TrackbarFunc(f)
|
||||||
|
case func(pos int):
|
||||||
|
win.trackbarHandle[name] = TrackbarFunc(f)
|
||||||
|
case func(pos int, param ...interface{}):
|
||||||
|
win.trackbarHandle[name] = TrackbarFunc(f)
|
||||||
|
default:
|
||||||
|
panic("unknow func type!")
|
||||||
|
}
|
||||||
|
|
||||||
|
win.trackbarVal[name] = value
|
||||||
|
win.trackbarMax[name] = count
|
||||||
|
//win.trackbarHandle[name] = on_changed
|
||||||
|
win.trackbarName[name] = bar_name
|
||||||
|
|
||||||
|
if len(param) > 0 {
|
||||||
|
win.trackbarParam[name] = param
|
||||||
|
} else {
|
||||||
|
win.trackbarParam[name] = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
rv := C.GoOpenCV_CreateTrackbar(bar_name, win.name_c,
|
||||||
|
C.int(value), C.int(count))
|
||||||
|
return bool(rv != 0)
|
||||||
|
}
|
||||||
|
func destroyTrackbar(barName_, winName_ *C.char) {
|
||||||
|
C.GoOpenCV_DestroyTrackbar(barName_, winName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
//export goTrackbarCallback
|
||||||
|
func goTrackbarCallback(barName_, winName_ *C.char, pos C.int) {
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
winName := C.GoString(winName_)
|
||||||
|
barName := C.GoString(barName_)
|
||||||
|
|
||||||
|
win, ok := allWindows[winName]
|
||||||
|
if !ok { return }
|
||||||
|
|
||||||
|
trackbarHandle, ok := win.trackbarHandle[barName]
|
||||||
|
if !ok { return }
|
||||||
|
if trackbarHandle == nil { return }
|
||||||
|
|
||||||
|
if fa, ok := trackbarHandle.(func(pos int)); ok {
|
||||||
|
fa(int(pos))
|
||||||
|
} else if fb, ok := trackbarHandle.(func(pos int, param ...interface{})); ok {
|
||||||
|
param := win.trackbarParam[barName]
|
||||||
|
if param != nil {
|
||||||
|
fb(int(pos), param...)
|
||||||
|
} else {
|
||||||
|
fb(int(pos))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* retrieve or set trackbar position */
|
||||||
|
func (win *Window)GetTrackbarPos(name string) (value, max int) {
|
||||||
|
rv := C.cvGetTrackbarPos(win.trackbarName[name], win.name_c)
|
||||||
|
return int(rv), win.trackbarMax[name]
|
||||||
|
}
|
||||||
|
func (win *Window)SetTrackbarPos(name string, pos int) {
|
||||||
|
C.cvSetTrackbarPos(win.trackbarName[name], win.name_c, C.int(pos))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// window: mouse callback
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_EVENT_MOUSEMOVE = int(C.CV_EVENT_MOUSEMOVE )
|
||||||
|
CV_EVENT_LBUTTONDOWN = int(C.CV_EVENT_LBUTTONDOWN )
|
||||||
|
CV_EVENT_RBUTTONDOWN = int(C.CV_EVENT_RBUTTONDOWN )
|
||||||
|
CV_EVENT_MBUTTONDOWN = int(C.CV_EVENT_MBUTTONDOWN )
|
||||||
|
CV_EVENT_LBUTTONUP = int(C.CV_EVENT_LBUTTONUP )
|
||||||
|
CV_EVENT_RBUTTONUP = int(C.CV_EVENT_RBUTTONUP )
|
||||||
|
CV_EVENT_MBUTTONUP = int(C.CV_EVENT_MBUTTONUP )
|
||||||
|
CV_EVENT_LBUTTONDBLCLK = int(C.CV_EVENT_LBUTTONDBLCLK)
|
||||||
|
CV_EVENT_RBUTTONDBLCLK = int(C.CV_EVENT_RBUTTONDBLCLK)
|
||||||
|
CV_EVENT_MBUTTONDBLCLK = int(C.CV_EVENT_MBUTTONDBLCLK)
|
||||||
|
|
||||||
|
CV_EVENT_FLAG_LBUTTON = int(C.CV_EVENT_FLAG_LBUTTON )
|
||||||
|
CV_EVENT_FLAG_RBUTTON = int(C.CV_EVENT_FLAG_RBUTTON )
|
||||||
|
CV_EVENT_FLAG_MBUTTON = int(C.CV_EVENT_FLAG_MBUTTON )
|
||||||
|
CV_EVENT_FLAG_CTRLKEY = int(C.CV_EVENT_FLAG_CTRLKEY )
|
||||||
|
CV_EVENT_FLAG_SHIFTKEY = int(C.CV_EVENT_FLAG_SHIFTKEY)
|
||||||
|
CV_EVENT_FLAG_ALTKEY = int(C.CV_EVENT_FLAG_ALTKEY )
|
||||||
|
)
|
||||||
|
|
||||||
|
/* assign callback for mouse events */
|
||||||
|
func (win *Window)SetMouseCallback(on_mouse MouseFunc, param ...interface{}) {
|
||||||
|
|
||||||
|
switch f := on_mouse.(type) {
|
||||||
|
case MouseFuncA:
|
||||||
|
win.mouseHandle = MouseFunc(f)
|
||||||
|
case MouseFuncB:
|
||||||
|
win.mouseHandle = MouseFunc(f)
|
||||||
|
case func(event, x, y, flags int):
|
||||||
|
win.mouseHandle = MouseFunc(f)
|
||||||
|
case func(event, x, y, flags int, param ...interface{}):
|
||||||
|
win.mouseHandle = MouseFunc(f)
|
||||||
|
default:
|
||||||
|
panic("unknow func type!")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(param) > 0 {
|
||||||
|
win.param = param
|
||||||
|
} else {
|
||||||
|
win.param = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//export goMouseCallback
|
||||||
|
func goMouseCallback(name *C.char, event, x, y, flags C.int) {
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
winName := C.GoString(name)
|
||||||
|
win, ok := allWindows[winName]
|
||||||
|
|
||||||
|
if !ok { return }
|
||||||
|
if win.mouseHandle == nil { return }
|
||||||
|
|
||||||
|
if fa, ok := win.mouseHandle.(func(event, x, y, flags int)); ok {
|
||||||
|
fa(int(event), int(x), int(y), int(flags))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if fb, ok := win.mouseHandle.(func(event, x, y, flags int, param ...interface{})); ok {
|
||||||
|
if win.param != nil {
|
||||||
|
fb(int(event), int(x), int(y), int(flags), win.param...)
|
||||||
|
} else {
|
||||||
|
fb(int(event), int(x), int(y), int(flags))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// window: destroy
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/* destroy window and all the trackers associated with it */
|
||||||
|
func (win *Window)Destroy() {
|
||||||
|
C.cvDestroyWindow(win.name_c)
|
||||||
|
delete(allWindows, win.name)
|
||||||
|
|
||||||
|
for _, bar_name := range win.trackbarName {
|
||||||
|
C.GoOpenCV_DestroyTrackbar(bar_name, win.name_c)
|
||||||
|
C.free(unsafe.Pointer(bar_name))
|
||||||
|
}
|
||||||
|
C.free(unsafe.Pointer(win.name_c))
|
||||||
|
win.name_c = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/* destroy window and all the trackers associated with it */
|
||||||
|
func DestroyAllWindows() {
|
||||||
|
for _, win := range allWindows {
|
||||||
|
win.Destroy()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// image utils
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const (
|
||||||
|
/* 8bit, color or not */
|
||||||
|
CV_LOAD_IMAGE_UNCHANGED = int(C.CV_LOAD_IMAGE_UNCHANGED)
|
||||||
|
/* 8bit, gray */
|
||||||
|
CV_LOAD_IMAGE_GRAYSCALE = int(C.CV_LOAD_IMAGE_GRAYSCALE)
|
||||||
|
/* ?, color */
|
||||||
|
CV_LOAD_IMAGE_COLOR = int(C.CV_LOAD_IMAGE_COLOR)
|
||||||
|
/* any depth, ? */
|
||||||
|
CV_LOAD_IMAGE_ANYDEPTH = int(C.CV_LOAD_IMAGE_ANYDEPTH)
|
||||||
|
/* ?, any color */
|
||||||
|
CV_LOAD_IMAGE_ANYCOLOR = int(C.CV_LOAD_IMAGE_ANYCOLOR)
|
||||||
|
)
|
||||||
|
/* load image from file
|
||||||
|
iscolor can be a combination of above flags where CV_LOAD_IMAGE_UNCHANGED
|
||||||
|
overrides the other flags
|
||||||
|
using CV_LOAD_IMAGE_ANYCOLOR alone is equivalent to CV_LOAD_IMAGE_UNCHANGED
|
||||||
|
unless CV_LOAD_IMAGE_ANYDEPTH is specified images are converted to 8bit
|
||||||
|
*/
|
||||||
|
func LoadImage(filename string, iscolor_ ...int) *IplImage {
|
||||||
|
iscolor := CV_LOAD_IMAGE_COLOR
|
||||||
|
if len(iscolor_) > 0 {
|
||||||
|
iscolor = iscolor_[0]
|
||||||
|
}
|
||||||
|
name_c := C.CString(filename)
|
||||||
|
defer C.free(unsafe.Pointer(name_c))
|
||||||
|
|
||||||
|
rv := C.cvLoadImage(name_c, C.int(iscolor))
|
||||||
|
return (*IplImage)(rv)
|
||||||
|
}
|
||||||
|
func LoadImageM(filename string, iscolor int) *Mat {
|
||||||
|
name_c := C.CString(filename)
|
||||||
|
defer C.free(unsafe.Pointer(name_c))
|
||||||
|
|
||||||
|
rv := C.cvLoadImageM(name_c, C.int(iscolor))
|
||||||
|
return (*Mat)(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_IMWRITE_JPEG_QUALITY = int(C.CV_IMWRITE_JPEG_QUALITY)
|
||||||
|
CV_IMWRITE_PNG_COMPRESSION = int(C.CV_IMWRITE_PNG_COMPRESSION)
|
||||||
|
CV_IMWRITE_PXM_BINARY = int(C.CV_IMWRITE_PXM_BINARY)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* save image to file */
|
||||||
|
func SaveImage(filename string, image *IplImage, params int) int {
|
||||||
|
name_c := C.CString(filename)
|
||||||
|
defer C.free(unsafe.Pointer(name_c))
|
||||||
|
params_c := C.int(params)
|
||||||
|
rv := C.cvSaveImage(name_c, unsafe.Pointer(image), ¶ms_c)
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* decode image stored in the buffer */
|
||||||
|
func DecodeImage(buf unsafe.Pointer, iscolor int) *IplImage {
|
||||||
|
rv := C.cvDecodeImage((*C.CvMat)(buf), C.int(iscolor))
|
||||||
|
return (*IplImage)(rv)
|
||||||
|
}
|
||||||
|
func DecodeImageM(buf unsafe.Pointer, iscolor int) *Mat {
|
||||||
|
rv := C.cvDecodeImageM((*C.CvMat)(buf), C.int(iscolor))
|
||||||
|
return (*Mat)(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* encode image and store the result as a byte vector (single-row 8uC1 matrix) */
|
||||||
|
func EncodeImage(ext string, image unsafe.Pointer, params int) *Mat {
|
||||||
|
params_c := C.int(params)
|
||||||
|
ext_c := C.CString(ext)
|
||||||
|
defer C.free(unsafe.Pointer(ext_c))
|
||||||
|
|
||||||
|
rv := C.cvEncodeImage(ext_c, (image), ¶ms_c)
|
||||||
|
return (*Mat)(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_CVTIMG_FLIP = int(C.CV_CVTIMG_FLIP)
|
||||||
|
CV_CVTIMG_SWAP_RB = int(C.CV_CVTIMG_SWAP_RB)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* utility function: convert one image to another with optional vertical flip */
|
||||||
|
func ConvertImage(src, dst unsafe.Pointer, flags int) {
|
||||||
|
C.cvConvertImage(src, dst, C.int(flags))
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************\
|
||||||
|
* Working with Video Files and Cameras *
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
/* "black box" capture structure */
|
||||||
|
type Capture C.CvCapture
|
||||||
|
|
||||||
|
/* start capturing frames from video file */
|
||||||
|
func NewFileCapture(filename string) *Capture {
|
||||||
|
filename_c := C.CString(filename)
|
||||||
|
defer C.free(unsafe.Pointer(filename_c))
|
||||||
|
cap := C.cvCreateFileCapture(filename_c)
|
||||||
|
return (*Capture)(cap)
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_CAP_ANY = int(C.CV_CAP_ANY) // autodetect
|
||||||
|
|
||||||
|
CV_CAP_MIL = int(C.CV_CAP_MIL) // MIL proprietary drivers
|
||||||
|
|
||||||
|
CV_CAP_VFW = int(C.CV_CAP_VFW) // platform native
|
||||||
|
CV_CAP_V4L = int(C.CV_CAP_V4L)
|
||||||
|
CV_CAP_V4L2 = int(C.CV_CAP_V4L2)
|
||||||
|
|
||||||
|
CV_CAP_FIREWARE = int(C.CV_CAP_FIREWARE) // IEEE 1394 drivers
|
||||||
|
CV_CAP_FIREWIRE = int(C.CV_CAP_FIREWIRE)
|
||||||
|
CV_CAP_IEEE1394 = int(C.CV_CAP_IEEE1394)
|
||||||
|
CV_CAP_DC1394 = int(C.CV_CAP_DC1394)
|
||||||
|
CV_CAP_CMU1394 = int(C.CV_CAP_CMU1394)
|
||||||
|
|
||||||
|
CV_CAP_STEREO = int(C.CV_CAP_STEREO) // TYZX proprietary drivers
|
||||||
|
CV_CAP_TYZX = int(C.CV_CAP_TYZX)
|
||||||
|
CV_TYZX_LEFT = int(C.CV_TYZX_LEFT)
|
||||||
|
CV_TYZX_RIGHT = int(C.CV_TYZX_RIGHT)
|
||||||
|
CV_TYZX_COLOR = int(C.CV_TYZX_COLOR)
|
||||||
|
CV_TYZX_Z = int(C.CV_TYZX_Z)
|
||||||
|
|
||||||
|
CV_CAP_QT = int(C.CV_CAP_QT) // QuickTime
|
||||||
|
|
||||||
|
CV_CAP_UNICAP = int(C.CV_CAP_UNICAP) // Unicap drivers
|
||||||
|
|
||||||
|
CV_CAP_DSHOW = int(C.CV_CAP_DSHOW) // DirectShow (via videoInput)
|
||||||
|
|
||||||
|
CV_CAP_PVAPI = int(C.CV_CAP_PVAPI) // PvAPI, Prosilica GigE SDK
|
||||||
|
)
|
||||||
|
|
||||||
|
/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */
|
||||||
|
func NewCameraCapture(index int) *Capture {
|
||||||
|
cap := C.cvCreateCameraCapture(C.int(index))
|
||||||
|
return (*Capture)(cap)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* grab a frame, return 1 on success, 0 on fail.
|
||||||
|
this function is thought to be fast */
|
||||||
|
func (capture *Capture)GrabFrame() bool {
|
||||||
|
rv := C.cvGrabFrame((*C.CvCapture)(capture))
|
||||||
|
return (rv != C.int(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get the frame grabbed with cvGrabFrame(..)
|
||||||
|
This function may apply some frame processing like
|
||||||
|
frame decompression, flipping etc.
|
||||||
|
!!!DO NOT RELEASE or MODIFY the retrieved frame!!! */
|
||||||
|
func (capture *Capture)RetrieveFrame(streamIdx int) *IplImage {
|
||||||
|
rv := C.cvRetrieveFrame((*C.CvCapture)(capture), C.int(streamIdx))
|
||||||
|
return (*IplImage)(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Just a combination of cvGrabFrame and cvRetrieveFrame
|
||||||
|
!!!DO NOT RELEASE or MODIFY the retrieved frame!!! */
|
||||||
|
func (capture *Capture)QueryFrame() *IplImage {
|
||||||
|
rv := C.cvQueryFrame((*C.CvCapture)(capture))
|
||||||
|
return (*IplImage)(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* stop capturing/reading and free resources */
|
||||||
|
func (capture *Capture)Release() {
|
||||||
|
cap_c := (*C.CvCapture)(capture)
|
||||||
|
C.cvReleaseCapture(&cap_c)
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
CV_CAP_PROP_POS_MSEC = int(C.CV_CAP_PROP_POS_MSEC )
|
||||||
|
CV_CAP_PROP_POS_FRAMES = int(C.CV_CAP_PROP_POS_FRAMES )
|
||||||
|
CV_CAP_PROP_POS_AVI_RATIO = int(C.CV_CAP_PROP_POS_AVI_RATIO)
|
||||||
|
CV_CAP_PROP_FRAME_WIDTH = int(C.CV_CAP_PROP_FRAME_WIDTH )
|
||||||
|
CV_CAP_PROP_FRAME_HEIGHT = int(C.CV_CAP_PROP_FRAME_HEIGHT )
|
||||||
|
CV_CAP_PROP_FPS = int(C.CV_CAP_PROP_FPS )
|
||||||
|
CV_CAP_PROP_FOURCC = int(C.CV_CAP_PROP_FOURCC )
|
||||||
|
CV_CAP_PROP_FRAME_COUNT = int(C.CV_CAP_PROP_FRAME_COUNT )
|
||||||
|
CV_CAP_PROP_FORMAT = int(C.CV_CAP_PROP_FORMAT )
|
||||||
|
CV_CAP_PROP_MODE = int(C.CV_CAP_PROP_MODE )
|
||||||
|
CV_CAP_PROP_BRIGHTNESS = int(C.CV_CAP_PROP_BRIGHTNESS )
|
||||||
|
CV_CAP_PROP_CONTRAST = int(C.CV_CAP_PROP_CONTRAST )
|
||||||
|
CV_CAP_PROP_SATURATION = int(C.CV_CAP_PROP_SATURATION )
|
||||||
|
CV_CAP_PROP_HUE = int(C.CV_CAP_PROP_HUE )
|
||||||
|
CV_CAP_PROP_GAIN = int(C.CV_CAP_PROP_GAIN )
|
||||||
|
CV_CAP_PROP_EXPOSURE = int(C.CV_CAP_PROP_EXPOSURE )
|
||||||
|
CV_CAP_PROP_CONVERT_RGB = int(C.CV_CAP_PROP_CONVERT_RGB )
|
||||||
|
// CV_CAP_PROP_WHITE_BALANCE = int(C.CV_CAP_PROP_WHITE_BALANCE)
|
||||||
|
CV_CAP_PROP_RECTIFICATION = int(C.CV_CAP_PROP_RECTIFICATION)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* retrieve or set capture properties */
|
||||||
|
func (capture *Capture)GetProperty(property_id int) float64 {
|
||||||
|
rv := C.cvGetCaptureProperty((*C.CvCapture)(capture),
|
||||||
|
C.int(property_id),
|
||||||
|
)
|
||||||
|
return float64(rv)
|
||||||
|
}
|
||||||
|
func (capture *Capture)SetProperty(property_id int, value float64) int {
|
||||||
|
rv := C.cvSetCaptureProperty((*C.CvCapture)(capture),
|
||||||
|
C.int(property_id), C.double(value),
|
||||||
|
)
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the type of the capturer (eg, CV_CAP_V4W, CV_CAP_UNICAP),
|
||||||
|
// which is unknown if created with CV_CAP_ANY
|
||||||
|
func (capture *Capture)GetDomain() int {
|
||||||
|
rv := C.cvGetCaptureDomain((*C.CvCapture)(capture))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// VideoWriter
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/* "black box" video file writer structure */
|
||||||
|
type VideoWriter C.CvVideoWriter
|
||||||
|
|
||||||
|
// Prototype for CV_FOURCC so that swig can generate wrapper without mixing up the define
|
||||||
|
func FOURCC(c1, c2, c3, c4 int8) uint32 {
|
||||||
|
rv := C.GoOpenCV_FOURCC_(C.int(c1),C.int(c2),C.int(c3),C.int(c4))
|
||||||
|
return uint32(rv)
|
||||||
|
}
|
||||||
|
const (
|
||||||
|
/* Open Codec Selection Dialog (Windows only) */
|
||||||
|
CV_FOURCC_PROMPT = int(C.CV_FOURCC_PROMPT)
|
||||||
|
/* Use default codec for specified filename (Linux only) */
|
||||||
|
// CV_FOURCC_DEFAULT = int(C.CV_FOURCC_DEFAULT)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* initialize video file writer */
|
||||||
|
func NewVideoWriter(filename string,
|
||||||
|
fourcc int, fps float32,
|
||||||
|
frame_width, frame_height,
|
||||||
|
is_color int) *VideoWriter {
|
||||||
|
|
||||||
|
size := C.cvSize(C.int(frame_width), C.int(frame_height))
|
||||||
|
filename_c := C.CString(filename)
|
||||||
|
defer C.free(unsafe.Pointer(filename_c))
|
||||||
|
|
||||||
|
rv := C.cvCreateVideoWriter(filename_c,
|
||||||
|
C.int(fourcc), C.double(fps), size, C.int(is_color),
|
||||||
|
)
|
||||||
|
return (*VideoWriter)(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* write frame to video file */
|
||||||
|
func (writer *VideoWriter) WriteFrame(image *IplImage) int {
|
||||||
|
rv := C.cvWriteFrame((*C.CvVideoWriter)(writer), (*C.IplImage)(image))
|
||||||
|
return int(rv)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close video file writer */
|
||||||
|
func (writer *VideoWriter)Release() {
|
||||||
|
writer_c := (*C.CvVideoWriter)(writer)
|
||||||
|
C.cvReleaseVideoWriter(&writer_c)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************\
|
||||||
|
* --- END --- *
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
9
opencv/highgui_test.go
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package opencv
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLoadImage(t *testing.T) {
|
||||||
|
// t.Errorf("aaa")
|
||||||
|
}
|
||||||
76
opencv/opencv.c
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "opencv.h"
|
||||||
|
#include "_cgo_export.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// trackbar
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// trackbar data
|
||||||
|
struct TrackbarUserdata {
|
||||||
|
schar* win_name;
|
||||||
|
schar* bar_name;
|
||||||
|
int value;
|
||||||
|
};
|
||||||
|
static struct TrackbarUserdata *trackbar_list[1000];
|
||||||
|
static int trackbar_list_len = 0;
|
||||||
|
|
||||||
|
static void trackbarCallback(int pos, void* userdata) {
|
||||||
|
struct TrackbarUserdata *arg = (struct TrackbarUserdata*)userdata;
|
||||||
|
goTrackbarCallback(arg->bar_name, arg->win_name, pos);
|
||||||
|
}
|
||||||
|
int GoOpenCV_CreateTrackbar(
|
||||||
|
char* trackbar_name, char* window_name,
|
||||||
|
int value, int count
|
||||||
|
) {
|
||||||
|
struct TrackbarUserdata *userdata = malloc(sizeof(*userdata));
|
||||||
|
trackbar_list[trackbar_list_len++] = userdata;
|
||||||
|
|
||||||
|
userdata->win_name = (schar*)window_name;
|
||||||
|
userdata->bar_name = (schar*)trackbar_name;
|
||||||
|
userdata->value = value;
|
||||||
|
|
||||||
|
return cvCreateTrackbar2(trackbar_name, window_name,
|
||||||
|
&(userdata->value), count,
|
||||||
|
trackbarCallback, userdata
|
||||||
|
);
|
||||||
|
}
|
||||||
|
void GoOpenCV_DestroyTrackbar(char* trackbar_name, char* window_name) {
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < trackbar_list_len; ++i) {
|
||||||
|
if(strcmp((char*)trackbar_list[i]->win_name, window_name)) continue;
|
||||||
|
if(strcmp((char*)trackbar_list[i]->bar_name, trackbar_name)) continue;
|
||||||
|
|
||||||
|
free(trackbar_list[i]);
|
||||||
|
trackbar_list[i] = trackbar_list[--trackbar_list_len];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// mouse callback
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void mouseCallback(int event, int x, int y, int flags, void* param) {
|
||||||
|
schar* name = (schar*)param;
|
||||||
|
goMouseCallback(name, event, x, y, flags);
|
||||||
|
}
|
||||||
|
void GoOpenCV_SetMouseCallback(const char* window_name) {
|
||||||
|
cvSetMouseCallback(window_name, mouseCallback, (void*)window_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// video writer args
|
||||||
|
unsigned GoOpenCV_FOURCC_(int c1, int c2, int c3, int c4) {
|
||||||
|
return (unsigned)CV_FOURCC(c1,c2,c3,c4);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
14
opencv/opencv.go
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package opencv
|
||||||
|
|
||||||
|
import(
|
||||||
|
// "image"
|
||||||
|
)
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// End
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
49
opencv/opencv.h
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// OpenCV Homepage: http://code.opencv.org
|
||||||
|
|
||||||
|
#ifndef _GO_OPENCV_BINDING_H_
|
||||||
|
#define _GO_OPENCV_BINDING_H_
|
||||||
|
|
||||||
|
#if defined(__linux) || defined(__linux__)
|
||||||
|
// OpenCV 2.0.x
|
||||||
|
# include <opencv/cv.h>
|
||||||
|
# include <opencv/highgui.h>
|
||||||
|
#elif defined(WIN32) || defined(_WIN32)
|
||||||
|
// OpenCV 2.4.x
|
||||||
|
# include <opencv/cv.h>
|
||||||
|
# include <opencv/highgui.h>
|
||||||
|
# include <opencv2/photo/photo_c.h>
|
||||||
|
# include <opencv2/imgproc/imgproc_c.h>
|
||||||
|
#else // Mac OS X ?
|
||||||
|
// OpenCV 2.4.x ?
|
||||||
|
# include <opencv/cv.h>
|
||||||
|
# include <opencv/highgui.h>
|
||||||
|
# include <opencv2/photo/photo_c.h>
|
||||||
|
# include <opencv2/imgproc/imgproc_c.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Trackbar
|
||||||
|
int GoOpenCV_CreateTrackbar(
|
||||||
|
char* trackbar_name, char* window_name,
|
||||||
|
int value, int count
|
||||||
|
);
|
||||||
|
void GoOpenCV_DestroyTrackbar(
|
||||||
|
char* trackbar_name, char* window_name
|
||||||
|
);
|
||||||
|
|
||||||
|
// mouse callback
|
||||||
|
void GoOpenCV_SetMouseCallback(
|
||||||
|
const char* window_name
|
||||||
|
);
|
||||||
|
|
||||||
|
// video writer args
|
||||||
|
unsigned GoOpenCV_FOURCC_(
|
||||||
|
int c1, int c2, int c3, int c4
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif // _GO_OPENCV_BINDING_H_
|
||||||
|
|
||||||
|
|
||||||
79
samples/edge.go
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"code.google.com/p/go-opencv/opencv"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
filename := "../images/lena.jpg"
|
||||||
|
if len(os.Args) == 2 {
|
||||||
|
filename = os.Args[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
image := opencv.LoadImage(filename)
|
||||||
|
if image == nil {
|
||||||
|
panic("LoadImage fail")
|
||||||
|
}
|
||||||
|
defer image.Release()
|
||||||
|
|
||||||
|
w := image.Width()
|
||||||
|
h := image.Height()
|
||||||
|
|
||||||
|
// Create the output image
|
||||||
|
cedge := opencv.CreateImage(w, h, opencv.IPL_DEPTH_8U, 3)
|
||||||
|
defer cedge.Release()
|
||||||
|
|
||||||
|
// Convert to grayscale
|
||||||
|
gray := opencv.CreateImage(w, h, opencv.IPL_DEPTH_8U, 1)
|
||||||
|
edge := opencv.CreateImage(w, h, opencv.IPL_DEPTH_8U, 1)
|
||||||
|
defer gray.Release()
|
||||||
|
defer edge.Release()
|
||||||
|
|
||||||
|
opencv.CvtColor(image, gray, opencv.CV_BGR2GRAY)
|
||||||
|
|
||||||
|
win := opencv.NewWindow("Edge")
|
||||||
|
defer win.Destroy()
|
||||||
|
|
||||||
|
win.SetMouseCallback(func(event, x, y, flags int, param ...interface{}) {
|
||||||
|
fmt.Printf("event = %d, x = %d, y = %d, flags = %d\n",
|
||||||
|
event, x, y, flags,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
win.CreateTrackbar("Thresh", 1, 100, func(pos int, param ...interface{}) {
|
||||||
|
edge_thresh := pos
|
||||||
|
|
||||||
|
opencv.Smooth(gray, edge, opencv.CV_BLUR, 3, 3, 0, 0)
|
||||||
|
opencv.Not(gray, edge)
|
||||||
|
|
||||||
|
// Run the edge detector on grayscale
|
||||||
|
opencv.Canny(gray, edge, float64(edge_thresh), float64(edge_thresh*3), 3)
|
||||||
|
|
||||||
|
opencv.Zero(cedge)
|
||||||
|
// copy edge points
|
||||||
|
opencv.Copy(image, cedge, edge)
|
||||||
|
|
||||||
|
win.ShowImage(cedge)
|
||||||
|
|
||||||
|
fmt.Printf("pos = %d\n", pos)
|
||||||
|
})
|
||||||
|
win.ShowImage(image)
|
||||||
|
|
||||||
|
for {
|
||||||
|
key := opencv.WaitKey(20)
|
||||||
|
if key == 27 {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
43
samples/hellocv.go
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"code.google.com/p/go-opencv/opencv"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
filename := "../images/lena.jpg"
|
||||||
|
if len(os.Args) == 2 {
|
||||||
|
filename = os.Args[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
image := opencv.LoadImage(filename)
|
||||||
|
if image == nil {
|
||||||
|
panic("LoadImage fail")
|
||||||
|
}
|
||||||
|
defer image.Release()
|
||||||
|
|
||||||
|
win := opencv.NewWindow("Go-OpenCV")
|
||||||
|
defer win.Destroy()
|
||||||
|
|
||||||
|
win.SetMouseCallback(func(event, x, y, flags int) {
|
||||||
|
fmt.Printf("event = %d, x = %d, y = %d, flags = %d\n",
|
||||||
|
event, x, y, flags,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
win.CreateTrackbar("Thresh", 1, 100, func(pos int) {
|
||||||
|
fmt.Printf("pos = %d\n", pos)
|
||||||
|
})
|
||||||
|
|
||||||
|
win.ShowImage(image)
|
||||||
|
|
||||||
|
opencv.WaitKey(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
94
samples/inpaint.go
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"code.google.com/p/go-opencv/opencv"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
filename := "../images/fruits.jpg"
|
||||||
|
if len(os.Args) == 2 {
|
||||||
|
filename = os.Args[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
img0 := opencv.LoadImage(filename)
|
||||||
|
if img0 == nil {
|
||||||
|
panic("LoadImage fail")
|
||||||
|
}
|
||||||
|
defer img0.Release()
|
||||||
|
|
||||||
|
fmt.Print("Hot keys: \n",
|
||||||
|
"\tESC - quit the program\n",
|
||||||
|
"\tr - restore the original image\n",
|
||||||
|
"\ti or ENTER - run inpainting algorithm\n",
|
||||||
|
"\t\t(before running it, paint something on the image)\n",
|
||||||
|
)
|
||||||
|
|
||||||
|
img := img0.Clone()
|
||||||
|
inpainted := img0.Clone()
|
||||||
|
inpaint_mask := opencv.CreateImage(img0.Width(), img0.Height(), 8, 1)
|
||||||
|
|
||||||
|
opencv.Zero(inpaint_mask)
|
||||||
|
//opencv.Zero( inpainted )
|
||||||
|
|
||||||
|
win := opencv.NewWindow("image")
|
||||||
|
defer win.Destroy()
|
||||||
|
|
||||||
|
prev_pt := opencv.Point{-1, -1}
|
||||||
|
win.SetMouseCallback(func(event, x, y, flags int, param ...interface{}) {
|
||||||
|
if img == nil {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if event == opencv.CV_EVENT_LBUTTONUP ||
|
||||||
|
(flags&opencv.CV_EVENT_FLAG_LBUTTON) == 0 {
|
||||||
|
prev_pt = opencv.Point{-1, -1}
|
||||||
|
} else if event == opencv.CV_EVENT_LBUTTONDOWN {
|
||||||
|
prev_pt = opencv.Point{x, y}
|
||||||
|
} else if event == opencv.CV_EVENT_MOUSEMOVE &&
|
||||||
|
(flags&opencv.CV_EVENT_FLAG_LBUTTON) != 0 {
|
||||||
|
pt := opencv.Point{x, y}
|
||||||
|
if prev_pt.X < 0 {
|
||||||
|
prev_pt = pt
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb := opencv.ScalarAll(255.0)
|
||||||
|
opencv.Line(inpaint_mask, prev_pt, pt, rgb, 5, 8, 0)
|
||||||
|
opencv.Line(img, prev_pt, pt, rgb, 5, 8, 0)
|
||||||
|
prev_pt = pt
|
||||||
|
|
||||||
|
win.ShowImage(img)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
win.ShowImage(img)
|
||||||
|
opencv.WaitKey(0)
|
||||||
|
|
||||||
|
win2 := opencv.NewWindow("inpainted image")
|
||||||
|
defer win2.Destroy()
|
||||||
|
win2.ShowImage(inpainted)
|
||||||
|
|
||||||
|
for {
|
||||||
|
key := opencv.WaitKey(20)
|
||||||
|
if key == 27 {
|
||||||
|
os.Exit(0)
|
||||||
|
} else if key == 'r' {
|
||||||
|
opencv.Zero(inpaint_mask)
|
||||||
|
opencv.Copy(img0, img, nil)
|
||||||
|
win.ShowImage(img)
|
||||||
|
} else if key == 'i' || key == '\n' {
|
||||||
|
opencv.Inpaint(img, inpaint_mask, inpainted, 3,
|
||||||
|
opencv.CV_INPAINT_TELEA,
|
||||||
|
)
|
||||||
|
win2.ShowImage(inpainted)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
77
samples/player.go
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
// Copyright 2011 <chaishushan@gmail.com>. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"code.google.com/p/go-opencv/opencv"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
filename := "../data/???.avi"
|
||||||
|
if len(os.Args) == 2 {
|
||||||
|
filename = os.Args[1]
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Usage: go run player.go videoname\n")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
cap := opencv.NewFileCapture(filename)
|
||||||
|
if cap == nil {
|
||||||
|
panic("can not open video")
|
||||||
|
}
|
||||||
|
defer cap.Release()
|
||||||
|
|
||||||
|
win := opencv.NewWindow("GoOpenCV: VideoPlayer")
|
||||||
|
defer win.Destroy()
|
||||||
|
|
||||||
|
fps := int(cap.GetProperty(opencv.CV_CAP_PROP_FPS))
|
||||||
|
frames := int(cap.GetProperty(opencv.CV_CAP_PROP_FRAME_COUNT))
|
||||||
|
stop := false
|
||||||
|
|
||||||
|
win.SetMouseCallback(func(event, x, y, flags int) {
|
||||||
|
if flags&opencv.CV_EVENT_LBUTTONDOWN != 0 {
|
||||||
|
stop = !stop
|
||||||
|
if stop {
|
||||||
|
fmt.Printf("status: stop")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("status: palying")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
win.CreateTrackbar("Seek", 1, frames, func(pos int) {
|
||||||
|
cur_pos := int(cap.GetProperty(opencv.CV_CAP_PROP_POS_FRAMES))
|
||||||
|
|
||||||
|
if pos != cur_pos {
|
||||||
|
cap.SetProperty(opencv.CV_CAP_PROP_POS_FRAMES, float64(pos))
|
||||||
|
fmt.Printf("Seek to %d(%d)\n", pos, frames)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
for {
|
||||||
|
if !stop {
|
||||||
|
img := cap.QueryFrame()
|
||||||
|
if img == nil { break }
|
||||||
|
|
||||||
|
frame_pos := int(cap.GetProperty(opencv.CV_CAP_PROP_POS_FRAMES))
|
||||||
|
if frame_pos >= frames { break }
|
||||||
|
win.SetTrackbarPos("Seek", frame_pos)
|
||||||
|
|
||||||
|
win.ShowImage(img)
|
||||||
|
key := opencv.WaitKey(1000/fps)
|
||||||
|
if key == 27 { os.Exit(0) }
|
||||||
|
} else {
|
||||||
|
key := opencv.WaitKey(20)
|
||||||
|
if key == 27 { os.Exit(0) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
opencv.WaitKey(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BIN
samples/screenshot/go-edge.jpg
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
samples/screenshot/go-inpaint.jpg
Normal file
|
After Width: | Height: | Size: 103 KiB |