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

SIFT custom #1186

merged 2 commits into from
Jul 22, 2024

Conversation

carpino
Copy link
Contributor

@carpino carpino commented Jul 20, 2024

Hello,

ive crearted a procedure to instantiate a SIFT object with custom values,

ive created a new procedure leaving untouched the default unparametrized procedure,

hope this will be included in the dev branch,

(ive closed the pull request just created in the wrong branch)

@deadprogram

features2d.go Outdated
@@ -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 {

features2d.go Outdated
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)))}

features2d.h Outdated
@@ -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);

features2d.cpp Outdated
@@ -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) {

@deadprogram
Copy link
Member

Hello @carpino please see my suggested changes inline.

See https://github.com/hybridgroup/gocv/blob/release/CONTRIBUTING.md#how-to-add-a-function-from-opencv-to-gocv for some explanation.

Also, can you please add a smoke test as described in the contribution guidelines?

Thank you!

@carpino
Copy link
Contributor Author

carpino commented Jul 20, 2024

Hello @carpino please see my suggested changes inline.

See https://github.com/hybridgroup/gocv/blob/release/CONTRIBUTING.md#how-to-add-a-function-from-opencv-to-gocv for some explanation.

Also, can you please add a smoke test as described in the contribution guidelines?

Thank you!

Hi @deadprogram, thanks for the quick response, changed the name according to your suggestion and contribution guidelines,

added smoke test that follow the structure of the test for SIFT without params, checking the correct number of features, generally I should check for a number of features not greater than the params but for the image used in the test SIFT extract an higher number of features if created without params, so I check an inequality

@deadprogram
Copy link
Member

Thanks for the addition @carpino now squash/merging.

@deadprogram deadprogram merged commit 674c565 into hybridgroup:dev Jul 22, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants