Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIFT custom #1186

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions features2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,11 @@ SIFT SIFT_Create() {
return new cv::Ptr<cv::SIFT>(cv::SIFT::create());
}

SIFT SIFT_CreateCustom(int nfeatures, int nOctaveLayers, double contrastThreshold, double edgeThreshold, double sigma) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SIFT SIFT_CreateCustom(int nfeatures, int nOctaveLayers, double contrastThreshold, double edgeThreshold, double sigma) {
SIFT SIFT_CreateWithParams(int nfeatures, int nOctaveLayers, double contrastThreshold, double edgeThreshold, double sigma) {

return new cv::Ptr<cv::SIFT>(cv::SIFT::create(nfeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma));
}


void SIFT_Close(SIFT d) {
delete d;
}
Expand Down
33 changes: 33 additions & 0 deletions features2d.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,39 @@ func NewSIFT() SIFT {
return SIFT{p: unsafe.Pointer(C.SIFT_Create())}
}

func NewSIFTCustom(nfeatures *int, nOctaveLayers *int, contrastThreshold *float64, edgeThreshold *float64, sigma *float64) SIFT {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func NewSIFTCustom(nfeatures *int, nOctaveLayers *int, contrastThreshold *float64, edgeThreshold *float64, sigma *float64) SIFT {
func NewSIFTWithParams(nfeatures *int, nOctaveLayers *int, contrastThreshold *float64, edgeThreshold *float64, sigma *float64) SIFT {

numFeatures := 0
if nfeatures != nil {
numFeatures = *nfeatures
}

numOctaveLayers := 3

if nOctaveLayers != nil {
numOctaveLayers = *nOctaveLayers
}

var numContrastThreshold float64 = 0.04

if contrastThreshold != nil {
numContrastThreshold = *contrastThreshold
}

var numEdgeThreshold float64 = 10

if edgeThreshold != nil {
numEdgeThreshold = *edgeThreshold
}

var numSigma float64 = 1.6

if sigma != nil {
numSigma = *sigma
}

return SIFT{p: unsafe.Pointer(C.SIFT_CreateCustom(C.int(numFeatures), C.int(numOctaveLayers), C.double(numContrastThreshold), C.double(numEdgeThreshold), C.double(numSigma)))}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return SIFT{p: unsafe.Pointer(C.SIFT_CreateCustom(C.int(numFeatures), C.int(numOctaveLayers), C.double(numContrastThreshold), C.double(numEdgeThreshold), C.double(numSigma)))}
return SIFT{p: unsafe.Pointer(C.SIFT_CreateWithParams(C.int(numFeatures), C.int(numOctaveLayers), C.double(numContrastThreshold), C.double(numEdgeThreshold), C.double(numSigma)))}

}

// Close SIFT.
func (d *SIFT) Close() error {
C.SIFT_Close((C.SIFT)(d.p))
Expand Down
1 change: 1 addition & 0 deletions features2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ struct MultiDMatches FlannBasedMatcher_KnnMatch(FlannBasedMatcher f, Mat query,
void DrawKeyPoints(Mat src, struct KeyPoints kp, Mat dst, const Scalar s, int flags);

SIFT SIFT_Create();
SIFT SIFT_CreateCustom(int nfeatures, int nOctaveLayers, double contrastThreshold, double edgeThreshold, double sigma);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SIFT SIFT_CreateCustom(int nfeatures, int nOctaveLayers, double contrastThreshold, double edgeThreshold, double sigma);
SIFT SIFT_CreateWithParams(int nfeatures, int nOctaveLayers, double contrastThreshold, double edgeThreshold, double sigma);

void SIFT_Close(SIFT f);
struct KeyPoints SIFT_Detect(SIFT f, Mat src);
struct KeyPoints SIFT_Compute(SIFT f, Mat src, struct KeyPoints kp, Mat desc);
Expand Down
Loading