Cleanup swig files.
This commit is contained in:
parent
27818da249
commit
af3c33e58e
5 changed files with 75 additions and 69 deletions
64
gocv/gocv.go
64
gocv/gocv.go
|
|
@ -3,67 +3,3 @@ package gocv
|
||||||
// #cgo CXXFLAGS: -std=c++11
|
// #cgo CXXFLAGS: -std=c++11
|
||||||
// #cgo darwin pkg-config: opencv
|
// #cgo darwin pkg-config: opencv
|
||||||
import "C"
|
import "C"
|
||||||
import "github.com/gonum/matrix/mat64"
|
|
||||||
|
|
||||||
func NewGcvPoint3f32(x, y, z float64) GcvPoint3f32_ {
|
|
||||||
return NewGcvPoint3f32_(float32(x), float32(y), float32(z))
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGcvPoint3f64(x, y, z float64) GcvPoint3f64_ {
|
|
||||||
return NewGcvPoint3f64_(float64(x), float64(y), float64(z))
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGcvPoint2f32(x, y float64) GcvPoint2f32_ {
|
|
||||||
return NewGcvPoint2f32_(float32(x), float32(y))
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGcvPoint2f64(x, y float64) GcvPoint2f64_ {
|
|
||||||
return NewGcvPoint2f64_(float64(x), float64(y))
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGcvSize2f32(x, y float64) GcvSize2f32_ {
|
|
||||||
return NewGcvSize2f32_(float32(x), float32(y))
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGcvSize2f64(x, y float64) GcvSize2f64_ {
|
|
||||||
return NewGcvSize2f64_(float64(x), float64(y))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert Mat, which defined by SWIG, to *mat64.Dense.
|
|
||||||
// The reason is the latter is much easier to handle
|
|
||||||
// in Go.
|
|
||||||
// GcvMat is assumed to be 2-dimensional matrix.
|
|
||||||
func MatToMat64(mat Mat) *mat64.Dense {
|
|
||||||
col := mat.GetCols()
|
|
||||||
row := mat.GetRows()
|
|
||||||
|
|
||||||
data := []float64{}
|
|
||||||
|
|
||||||
for i := 0; i < row; i++ {
|
|
||||||
for j := 0; j < col; j++ {
|
|
||||||
if fltPtr, ok := mat.GcvAtf64(i, j).(*float64); ok {
|
|
||||||
data = append(data, *fltPtr)
|
|
||||||
} else {
|
|
||||||
panic("Non *float64 passed to MatToMat64")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mat64.NewDense(row, col, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert *mat64.Dense to Mat
|
|
||||||
func ToMat(mat *mat64.Dense) Mat {
|
|
||||||
row, col := mat.Dims()
|
|
||||||
|
|
||||||
rawData := NewGcvFloat64Vector(int64(row * col))
|
|
||||||
|
|
||||||
for i := 0; i < row; i++ {
|
|
||||||
for j := 0; j < col; j++ {
|
|
||||||
rawData.Set(i*col+j, mat.At(i, j))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ToMat_(row, col, rawData)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
%module gocv
|
%module gocv
|
||||||
|
|
||||||
%{
|
|
||||||
#include "gocv_calib3d.hpp"
|
|
||||||
%}
|
|
||||||
|
|
||||||
%include "gocv_core.i"
|
%include "gocv_core.i"
|
||||||
%include "gocv_calib3d.hpp"
|
%include "gocv_calib3d.i"
|
||||||
|
|
|
||||||
5
gocv/gocv_calib3d.i
Normal file
5
gocv/gocv_calib3d.i
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "gocv_calib3d.hpp"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "gocv_calib3d.hpp"
|
||||||
69
gocv/gocv_core.go
Normal file
69
gocv/gocv_core.go
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
package gocv
|
||||||
|
|
||||||
|
// #cgo CXXFLAGS: -std=c++11
|
||||||
|
// #cgo darwin pkg-config: opencv
|
||||||
|
import "C"
|
||||||
|
import "github.com/gonum/matrix/mat64"
|
||||||
|
|
||||||
|
func NewGcvPoint3f32(x, y, z float64) GcvPoint3f32_ {
|
||||||
|
return NewGcvPoint3f32_(float32(x), float32(y), float32(z))
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGcvPoint3f64(x, y, z float64) GcvPoint3f64_ {
|
||||||
|
return NewGcvPoint3f64_(float64(x), float64(y), float64(z))
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGcvPoint2f32(x, y float64) GcvPoint2f32_ {
|
||||||
|
return NewGcvPoint2f32_(float32(x), float32(y))
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGcvPoint2f64(x, y float64) GcvPoint2f64_ {
|
||||||
|
return NewGcvPoint2f64_(float64(x), float64(y))
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGcvSize2f32(x, y float64) GcvSize2f32_ {
|
||||||
|
return NewGcvSize2f32_(float32(x), float32(y))
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGcvSize2f64(x, y float64) GcvSize2f64_ {
|
||||||
|
return NewGcvSize2f64_(float64(x), float64(y))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert Mat, which defined by SWIG, to *mat64.Dense.
|
||||||
|
// The reason is the latter is much easier to handle
|
||||||
|
// in Go.
|
||||||
|
// GcvMat is assumed to be 2-dimensional matrix.
|
||||||
|
func MatToMat64(mat Mat) *mat64.Dense {
|
||||||
|
col := mat.GetCols()
|
||||||
|
row := mat.GetRows()
|
||||||
|
|
||||||
|
data := []float64{}
|
||||||
|
|
||||||
|
for i := 0; i < row; i++ {
|
||||||
|
for j := 0; j < col; j++ {
|
||||||
|
if fltPtr, ok := mat.GcvAtf64(i, j).(*float64); ok {
|
||||||
|
data = append(data, *fltPtr)
|
||||||
|
} else {
|
||||||
|
panic("Non *float64 passed to MatToMat64")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mat64.NewDense(row, col, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert *mat64.Dense to Mat
|
||||||
|
func ToMat(mat *mat64.Dense) Mat {
|
||||||
|
row, col := mat.Dims()
|
||||||
|
|
||||||
|
rawData := NewGcvFloat64Vector(int64(row * col))
|
||||||
|
|
||||||
|
for i := 0; i < row; i++ {
|
||||||
|
for j := 0; j < col; j++ {
|
||||||
|
rawData.Set(i*col+j, mat.At(i, j))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ToMat_(row, col, rawData)
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue