Update README

This commit is contained in:
Chih-Wei Chang 2015-02-15 14:20:20 +08:00
parent 7a78947362
commit 165a4b1f4f

View file

@ -3,6 +3,8 @@ Go OpenCV binding
A Golang binding for [OpenCV](http://opencv.org/).
OpenCV 1.x C API bindings through CGO, and OpenCV 2+ C++ API through SWIG.
[**DISCLAIMER**](https://github.com/lazywei/go-opencv#disclaimer)
## Install
@ -31,32 +33,42 @@ go get code.google.com/p/go-opencv/trunk/opencv
cd ${GoOpenCVRoot}/trunk/samples && go run hellocv.go
```
## Usage
## [WIP] OpenCV2
Currently there are no too many readily instruction for usage. At this point, you can always refers to OpenCV's documentation. I'll try to keep all the bindings have the same signature as in OpenCV's C interface. However, please do note that sometimes the signature might slightly differ from the C interface due to Golang's type declaration conventions, for example:
After OpenCV 2.x+, the core team no longer develop and maintain C API. Therefore, CGO will not be used in CV2 binding. Instead, we are using SWIG for wrapping. The support for OpenCV2 is currently under development.
```
# The original signature in C interface.
void cvInitIntrinsicParams2D(
const CvMat* object_points, const CvMat* image_points,
const CvMat* npoints, CvSize image_size, CvMat* camera_matrix,
double aspect_ratio=1. )
If you want to use CV2's API, please refer to the code under `opencv2/` directory. There has no too much document for CV2 wrapper yet, but you can still find the usage example in `*_test.go`.
# We might put all *Mat types together, however
func InitIntrinsicParams2D(objectPoints, imagePoints, nPoints, cameraMatrix *Mat ...
# Or we might use "explicitly return" instead of C-style's pointer
func InitIntrinsicParams2D(objectPoints, imagePoints, nPoints, *Mat ...) (cameraMatrix *Mat)
```
## TODOs
- [ ] Better documents
- [ ] Split the big package into sub-packages corresponding to the modules described in [OpenCV API Reference](http://docs.opencv.org/modules/core/doc/intro.html)
- [ ] Clean up the codes with better coding style
Note that the basic data structures in OpenCV (e.g., `cv::Mat`, `cv::Point3f`) hasn't been wrapped fully yet. For now, we have some specific wrappers. We will try to wrapped those data structures fully as soon as possible.
## Example
### OpenCV2's initCameraMatrix2D
```go
package main
import "github.com/lazywei/go-opencv/opencv2/gcv_utils"
import "github.com/lazywei/go-opencv/opencv2/gcv_calib3d"
func main() {
objPts := gcv_utils.NewGcvPoint3fVector(int64(4))
objPts.Set(0, gcv_utils.GetPoint3f(0, 25, 0))
objPts.Set(1, gcv_utils.GetPoint3f(0, -25, 0))
objPts.Set(2, gcv_utils.GetPoint3f(-47, 25, 0))
objPts.Set(3, gcv_utils.GetPoint3f(-47, -25, 0))
imgPts := gcv_utils.NewGcvPoint2fVector(int64(4))
imgPts.Set(0, gcv_utils.GetPoint2f(1136.4140625, 1041.89208984))
imgPts.Set(1, gcv_utils.GetPoint2f(1845.33190918, 671.39581299))
imgPts.Set(2, gcv_utils.GetPoint2f(302.73373413, 634.79998779))
imgPts.Set(3, gcv_utils.GetPoint2f(1051.46154785, 352.76107788))
cameraMatrix := GcvInitCameraMatrix2D(objPts, imgPts)
}
```
### Resizing
```go
@ -124,5 +136,5 @@ You can find more samples at: https://github.com/lazywei/go-opencv/tree/master/s
## Disclaimer
This is a fork of [chai's go-opencv](https://github.com/chai2010/opencv). At the time of the fork (Dec 9, 2013) the original project was inactive, and hence I decide to host a fork on Github so people can contribute to this project easily. However, now it seems to be active again starting from Aug 25, 2014. Efforts to merge the two projects are very welcome.
This is a fork of [chai's go-opencv](https://github.com/chai2010/opencv), which has only OpenCV1 support through CGO. At the time of the fork (Dec 9, 2013) the original project was inactive, and hence I decide to host a fork on Github so people can contribute to this project easily. However, now it seems to be active again starting from Aug 25, 2014. Efforts to merge the two projects are very welcome.