-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Conversation
8da8de9
to
849eb70
Compare
PR Not Ready |
@LaurentBerger Is this PR ready? |
@alalek no I will try to write some test next week |
@alalek ready for review. Patch size for open_extra is it problem? |
Try to squash commits in opencv_extra (to drop intermediate history at least). |
a5b7fba
to
6a36066
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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).
modules/ximgproc/src/quaternion.cpp
Outdated
@@ -0,0 +1,206 @@ | |||
#include "precomp.hpp" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
modules/ximgproc/src/quaternion.cpp
Outdated
@@ -0,0 +1,206 @@ | |||
#include "precomp.hpp" | |||
using namespace std; | |||
using namespace cv; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
modules/ximgproc/src/quaternion.cpp
Outdated
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); |
There was a problem hiding this comment.
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.
modules/ximgproc/src/quaternion.cpp
Outdated
qplane[0] = plane[0].clone(); | ||
qplane[1] = -plane[1].clone(); | ||
qplane[2] = -plane[2].clone(); | ||
qplane[3] = -plane[3].clone(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
modules/ximgproc/src/quaternion.cpp
Outdated
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); |
There was a problem hiding this comment.
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;
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
modules/ximgproc/src/quaternion.cpp
Outdated
|
||
void qdft(InputArray _img, OutputArray _qimg, int flags, bool sideLeft) | ||
{ | ||
// CV_INSTRUMENT_REGION() |
There was a problem hiding this comment.
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.
900abeb
to
efa3f57
Compare
04f81fc
to
54413eb
Compare
* @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); |
There was a problem hiding this comment.
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
modules/ximgproc/src/quaternion.cpp
Outdated
}); | ||
/* | ||
qplane[0] = plane[0].clone(); | ||
qplane[1] = plane[1].clone(); |
There was a problem hiding this comment.
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.
modules/ximgproc/src/quaternion.cpp
Outdated
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); |
There was a problem hiding this comment.
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
e3580ce
to
d3e983d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
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
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/.