Skip to content

Search for matches between a color image patch and an input color image #1791

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

Merged
merged 2 commits into from
Nov 10, 2018

Conversation

LaurentBerger
Copy link
Contributor

@LaurentBerger LaurentBerger commented Sep 23, 2018

Merge with extra: opencv/opencv_extra#534

Sangwine, S. J., Ell, T. A. and Moxey C. E., Vector Phase Correlation, Electronics Letters, 37(25), 6 December 2001, 1513-5. http://dx.doi.org/10.1049/el:20011035

T. A. Ell and S. J. Sangwine. Decomposition of 2D hypercomplex Fourier transforms into pairs of complex Fourier transforms. In Moncef Gabbouj and Pauli Kuosmanen, editors, Proceedings of EUSIPCO 2000, Tenth European Signal Processing Conference, volume II, pages 1061–1064, Tampere, Finland, 5–8 September 2000. European Association for Signal Processing

Quaternion Toolbox for Matlab r . [Online]. Software library, written by Stephen Sangwine and Nicolas Le Bihan. Available: http://qtfm.sourceforge.net/.

@LaurentBerger LaurentBerger force-pushed the ColorMatchTemplate branch 2 times, most recently from 8da8de9 to 849eb70 Compare September 23, 2018 19:57
@LaurentBerger
Copy link
Contributor Author

PR Not Ready

@alalek
Copy link
Member

alalek commented Oct 12, 2018

@LaurentBerger Is this PR ready?

@LaurentBerger
Copy link
Contributor Author

@alalek no I will try to write some test next week

LaurentBerger added a commit to LaurentBerger/opencv_extra that referenced this pull request Oct 20, 2018
@LaurentBerger
Copy link
Contributor Author

@alalek ready for review. Patch size for open_extra is it problem?

@alalek
Copy link
Member

alalek commented Oct 21, 2018

Try to squash commits in opencv_extra (to drop intermediate history at least).

LaurentBerger added a commit to LaurentBerger/opencv_extra that referenced this pull request Oct 21, 2018
Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Well done!

Please take a look on comments below.


#ifndef __OPENCV_COLOR_MATCH_HPP__
#define __OPENCV_COLOR_MATCH_HPP__
#ifdef __cplusplus
Copy link
Member

Choose a reason for hiding this comment

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

#ifdef __cplusplus is not needed in .hpp files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

int main(int , char *[])
{
Mat imgLogo = imread("g:/lib/opencv/samples/data/opencv-logo.png", IMREAD_COLOR);
Mat imgColor = imread("g:/lib/opencv/samples/data/lena.jpg", IMREAD_COLOR);
Copy link
Member

Choose a reason for hiding this comment

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

Please avoid using of absolute paths. samples/data/... should be enough (or just file names).

@@ -0,0 +1,206 @@
#include "precomp.hpp"
Copy link
Member

Choose a reason for hiding this comment

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

Please add license header (modules sources / headers / tests, but not samples):

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

@@ -0,0 +1,206 @@
#include "precomp.hpp"
using namespace std;
using namespace cv;
Copy link
Member

Choose a reason for hiding this comment

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

using namespace cv; is not needed. All code is placed into cv namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

void createQuaternionImage(InputArray _img, OutputArray _qimg)
{
int type = _img.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
CV_Assert((depth == CV_8U || depth == CV_32F || depth == CV_64F) && _img.dims() == 2 && cn == 3);
Copy link
Member

Choose a reason for hiding this comment

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

It is better to use CV_Check*() macros for parameters checks.

qplane[0] = plane[0].clone();
qplane[1] = -plane[1].clone();
qplane[2] = -plane[2].clone();
qplane[3] = -plane[3].clone();
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps .clone() is not necessary here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

double maxVal;
Point pIdx;
minMaxLoc(dd, NULL, &maxVal, NULL, &pIdx);
ASSERT_LE(maxVal, 1e-5);
Copy link
Member

Choose a reason for hiding this comment

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

5 lines -> EXPECT_LE(cv::norm(corr, corrRef, NORM_INF), 1e-5);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

for (int i = 0; i < nb; i++, ptr0++, ptr1++, ptr2++, ptr3++)
{
double d = *ptr0 * *ptr0 + *ptr1 * *ptr1 + *ptr2 * *ptr2 + *ptr3 * *ptr3;
d = 1 / sqrt(d);
Copy link
Member

Choose a reason for hiding this comment

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

Try parallel .forEach():

    _img.copyTo(_qimg);
    Mat qimg = _qimg.getMat();
    qimg.forEach<Vec4d>([](Vec4d &p, const int * /*position*/) -> void {
        double d = p[0] * p[0] + p[1] * p[1] + p[2] * p[2] + p[3] * p[3];
        d = 1 / sqrt(d);
        p *= d;
    });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK


void qdft(InputArray _img, OutputArray _qimg, int flags, bool sideLeft)
{
// CV_INSTRUMENT_REGION()
Copy link
Member

Choose a reason for hiding this comment

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

It is OK to add this (into all exported "large enough" functions).
With ';' in the end.

@LaurentBerger
Copy link
Contributor Author

LaurentBerger added a commit to LaurentBerger/opencv_extra that referenced this pull request Oct 28, 2018
LaurentBerger added a commit to LaurentBerger/opencv_extra that referenced this pull request Nov 9, 2018
* @param img Source 8-bit, 32-bit or 64-bit image, with 3-channel image.
* @param qimg result CV_64FC4 a quaternion image( 4 chanels zero channel and B,G,R).
*/
CV_EXPORTS_W void createQuaternionImage(InputArray img, OutputArray qimg);
Copy link
Member

Choose a reason for hiding this comment

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

Please avoid extra indentation in namespaces

});
/*
qplane[0] = plane[0].clone();
qplane[1] = plane[1].clone();
Copy link
Member

Choose a reason for hiding this comment

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

I believe we can remove commented out code.

int type = _img.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
CV_Assert((depth == CV_64F) && _img.dims() == 2 && cn == 4);
vector<Mat> qplane(4), plane;
split(_img, plane);
Copy link
Member

Choose a reason for hiding this comment

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

qplane and plane are not needed anymore

Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Thank you!

@alalek alalek merged commit 67e1549 into opencv:master Nov 10, 2018
@LaurentBerger LaurentBerger deleted the ColorMatchTemplate branch November 11, 2018 09:37
l-bat pushed a commit to l-bat/opencv_extra that referenced this pull request Apr 24, 2019
Merge pull request opencv#516 from savuor:cvtcolor_bgr2gray_8u_15bits

* fixed perf data for PyrLK after bgr2gray 8u change

* fixed perf data for new bgr2gray coeffs

fixed issue #1754@contrib for ximgproc

Merge pull request opencv#528 from xoox:calib-release-object

Add new test data for extended camera calibration method (opencv#528)

* Reorder object points and image points

Now the feature points are in the order as the same set of the object
points, which makes the test data usable for testing calibration with
CALIB_RELEASE_OBJECT flag.

* Add one line to store calibration flags

opencv/modules/calib3d/test/test_cameracalibration.cpp must be sync with
this test data file.

* Add new test data for camera calibration

The new added calib2.dat is used for regression test of camera
calibration with CALIB_RELEASE_OBJECT flag.

* Add a line of data for the index of fixed point

The new proposed calibration flag CALIB_RELEASE_OBJECT is removed. And
the method selection is based on the range of the index of fixed point.
For minus values, standard calibration method will be chosen. Values in
a rational range will make the object-releasing calibration method
selected.

fixed "false alarm" test failures in opencv_test_objdetect (i.e. removed some errorneously detected "non-faces" from the regression data)

added sanity data for opencv_contrib/optflow module (since TVL1 optflow is now there and it does sanity check in perf tests)

Test data for opencv/opencv_contrib#1791

fixed perf data for mRGBA
rayonnant14 pushed a commit to rayonnant14/opencv_extra that referenced this pull request Oct 25, 2019
sl-sergei pushed a commit to sl-sergei/opencv_extra that referenced this pull request Aug 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants