Skip to content

Commit

Permalink
Remove untested code
Browse files Browse the repository at this point in the history
  • Loading branch information
kylycht committed Jun 7, 2018
1 parent 3698f28 commit 3d7de5a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 88 deletions.
8 changes: 0 additions & 8 deletions calib3d.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#include "calib3d.h"

double Fisheye_Calibrate(Mat objectPoints, Mat imagePoints, Size size, Mat k, Mat d, Mat rvecs, Mat tvecs) {
cv::Size sz(size.width, size.height);
return cv::fisheye::calibrate(*objectPoints, *imagePoints, sz, *k, *d, *rvecs, *tvecs);
}

void Fisheye_UndistortPoints(Mat distorted, Mat undistorted, Mat k, Mat d) {
cv::fisheye::undistortPoints(*distorted, *undistorted, *k, *d);
}

void Fisheye_UndistortImage(Mat distorted, Mat undistorted, Mat k, Mat d) {
cv::fisheye::undistortImage(*distorted, *undistorted, *k, *d);
Expand Down
18 changes: 0 additions & 18 deletions calib3d.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ package gocv
*/
import "C"

import (
"image"
)

// Calib is a wrapper around OpenCV's "Camera Calibration and 3D Reconstruction" of
// Fisheye Camera model
//
Expand Down Expand Up @@ -56,20 +52,6 @@ const (
CalibFixPrincipalPoint
)

// FisheyeCalibrate performs camera calibaration.
func FisheyeCalibrate(objectPoints, imagePoints, k, d Mat, rvecs, tvecs *Mat, size image.Point) float64 {
sz := C.struct_Size{
width: C.int(size.X),
height: C.int(size.Y),
}
return float64(C.Fisheye_Calibrate(objectPoints.Ptr(), imagePoints.Ptr(), sz, k.Ptr(), d.Ptr(), rvecs.Ptr(), tvecs.Ptr()))
}

// FisheyeUndistortPoints undistorts 2D points using fisheye model
func FisheyeUndistortPoints(distorted Mat, undistorted *Mat, k, d Mat) {
C.Fisheye_UndistortPoints(distorted.Ptr(), undistorted.Ptr(), k.Ptr(), d.Ptr())
}

// FisheyeUndistortImage transforms an image to compensate for fisheye lens distortion
func FisheyeUndistortImage(distorted Mat, undistorted *Mat, k, d Mat) {
C.Fisheye_UndistortImage(distorted.Ptr(), undistorted.Ptr(), k.Ptr(), d.Ptr())
Expand Down
2 changes: 0 additions & 2 deletions calib3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ extern "C" {
#include "core.h"

//Calib
double Fisheye_Calibrate(Mat objectPoints, Mat imagePoints, Size size, Mat k, Mat d, Mat rvecs, Mat tvecs);
void Fisheye_UndistortPoints(Mat distorted, Mat undistorted, Mat k, Mat d);
void Fisheye_UndistortImage(Mat distorted, Mat undistorted, Mat k, Mat d);
void Fisheye_UndistortImageWithKNewMat(Mat distorted, Mat undistorted, Mat k, Mat d, Mat knew);

Expand Down
60 changes: 0 additions & 60 deletions calib3d_test.go
Original file line number Diff line number Diff line change
@@ -1,69 +1,9 @@
package gocv

import (
"image"
"testing"
)

func TestFisheyeCalibrate(t *testing.T) {
img := IMRead("images/fisheye_sample.jpg", IMReadUnchanged)
if img.Empty() {
t.Error("Invalid read of Mat test")
}
defer img.Close()

obj := NewMat()
defer obj.Close()

obj.SetDoubleAt(0, 0, 1)
obj.SetDoubleAt(0, 1, 0)
obj.SetDoubleAt(0, 0, 1)
obj.SetDoubleAt(0, 0, 1)

dest := NewMat()
defer dest.Close()

k := NewMatWithSize(3, 3, MatTypeCV64F)
defer k.Close()

k.SetDoubleAt(0, 0, 689.21)
k.SetDoubleAt(0, 1, 0)
k.SetDoubleAt(0, 2, 1295.56)

k.SetDoubleAt(1, 0, 0)
k.SetDoubleAt(1, 1, 690.48)
k.SetDoubleAt(1, 2, 942.17)

k.SetDoubleAt(2, 0, 0)
k.SetDoubleAt(2, 1, 0)
k.SetDoubleAt(2, 2, 1)

d := NewMatWithSize(1, 4, MatTypeCV64F)
defer d.Close()

d.SetDoubleAt(0, 0, 0)
d.SetDoubleAt(0, 1, 0)
d.SetDoubleAt(0, 2, 0)
d.SetDoubleAt(0, 3, 0)

knew := NewMat()
defer knew.Close()

k.CopyTo(knew)

knew.SetDoubleAt(0, 0, 0.4*k.GetDoubleAt(0, 0))
knew.SetDoubleAt(1, 1, 0.4*k.GetDoubleAt(1, 1))

rvec := NewMatWithSize(10, 10, MatTypeCV64F)
defer rvec.Close()

tvec := NewMatWithSize(10, 10, MatTypeCV64F)
defer tvec.Close()

FisheyeCalibrate(obj, img, k, d, &rvec, &tvec, image.Point{X: 0, Y: 0})

}

func TestFisheyeUndistorImage(t *testing.T) {
img := IMRead("images/fisheye_sample.jpg", IMReadUnchanged)
if img.Empty() {
Expand Down

0 comments on commit 3d7de5a

Please sign in to comment.