|
|
|
|
@ -1175,32 +1175,25 @@ bool imageRotateMatch(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶mOut,
|
|
|
|
|
float m_Index = 0.0;
|
|
|
|
|
Mat roi;
|
|
|
|
|
roi.setTo(0);
|
|
|
|
|
for (int k = 0; k < selectRoi.rows; ++k)
|
|
|
|
|
{
|
|
|
|
|
for (int k = 0; k < selectRoi.rows; ++k) {
|
|
|
|
|
//uchar *ptr = selectRoi.row(k).data;
|
|
|
|
|
for (int m = 0; m < selectRoi.cols; ++m)
|
|
|
|
|
{
|
|
|
|
|
for (int m = 0; m < selectRoi.cols; ++m) {
|
|
|
|
|
//qDebug() << "k:" << k << "m :" << m ;
|
|
|
|
|
float dis = luffy_math::disofPoints(Point2f(m, k), Point2f(wheelRoi.cols / 2.0, wheelRoi.rows / 2.0));
|
|
|
|
|
if (dis > outterRadius || dis < innerRadius)
|
|
|
|
|
{
|
|
|
|
|
if (dis > outterRadius || dis < innerRadius) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
float nIndex = luffy_math::caculAngle(Point2f(wheelRoi.cols / 2.0, wheelRoi.rows / 2.0), Point2f(m, k));
|
|
|
|
|
int flag = false;
|
|
|
|
|
for (int y = 0; y < candiateAngleRange.size(); ++y)
|
|
|
|
|
{
|
|
|
|
|
for (int y = 0; y < candiateAngleRange.size(); ++y) {
|
|
|
|
|
|
|
|
|
|
if (candiateAngleRange[y][0] > candiateAngleRange[y][1])
|
|
|
|
|
{
|
|
|
|
|
if ((nIndex >= candiateAngleRange[y][0] && nIndex < 360) || (nIndex >=0 && nIndex <=candiateAngleRange[y][1]))
|
|
|
|
|
{
|
|
|
|
|
if (candiateAngleRange[y][0] > candiateAngleRange[y][1]) {
|
|
|
|
|
if ((nIndex >= candiateAngleRange[y][0] && nIndex < 360) || (nIndex >=0 && nIndex <=candiateAngleRange[y][1])) {
|
|
|
|
|
const Mat& templ = templates[nIndex];
|
|
|
|
|
|
|
|
|
|
int nwidth = templ.cols;
|
|
|
|
|
int nheight = templ.rows;
|
|
|
|
|
if ((m + nwidth >= outterRadius * 2) || (k + nheight > outterRadius * 2))
|
|
|
|
|
{
|
|
|
|
|
if ((m + nwidth >= outterRadius * 2) || (k + nheight > outterRadius * 2)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Mat matchRoi = selectRoi(Rect(m, k, nwidth, nheight));
|
|
|
|
|
@ -1208,8 +1201,7 @@ bool imageRotateMatch(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶mOut,
|
|
|
|
|
cv::matchTemplate(matchRoi, templ, val, CV_TM_CCOEFF_NORMED);
|
|
|
|
|
//float val = norm(matchRoi, templ, NORM_L2);
|
|
|
|
|
|
|
|
|
|
if (val.at<float>(0, 0) > maxVal)
|
|
|
|
|
{
|
|
|
|
|
if (val.at<float>(0, 0) > maxVal) {
|
|
|
|
|
maxVal = val.at<float>(0, 0);
|
|
|
|
|
p = Point(m, k);
|
|
|
|
|
m_Index = nIndex;
|
|
|
|
|
@ -1217,15 +1209,13 @@ bool imageRotateMatch(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶mOut,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (nIndex >= candiateAngleRange[y][0] && nIndex <= candiateAngleRange[y][1])
|
|
|
|
|
{
|
|
|
|
|
if (nIndex >= candiateAngleRange[y][0] && nIndex <= candiateAngleRange[y][1]) {
|
|
|
|
|
//selectRoi.at<uchar>(k, m) = 0;
|
|
|
|
|
const Mat& templ = templates[nIndex];
|
|
|
|
|
|
|
|
|
|
int nwidth = templ.cols;
|
|
|
|
|
int nheight = templ.rows;
|
|
|
|
|
if ((m + nwidth >= outterRadius * 2) || (k + nheight > outterRadius * 2))
|
|
|
|
|
{
|
|
|
|
|
if ((m + nwidth >= outterRadius * 2) || (k + nheight > outterRadius * 2)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Mat matchRoi = selectRoi(Rect(m, k, nwidth, nheight));
|
|
|
|
|
@ -1233,8 +1223,7 @@ bool imageRotateMatch(Mat & imgSrc, InputParam ¶mIn, OutputParam ¶mOut,
|
|
|
|
|
cv::matchTemplate(matchRoi, templ, val, CV_TM_CCOEFF_NORMED);
|
|
|
|
|
//float val = norm(matchRoi, templ, NORM_L2);
|
|
|
|
|
|
|
|
|
|
if (val.at<float>(0, 0) > maxVal)
|
|
|
|
|
{
|
|
|
|
|
if (val.at<float>(0, 0) > maxVal) {
|
|
|
|
|
maxVal = val.at<float>(0, 0);
|
|
|
|
|
p = Point(m, k);
|
|
|
|
|
m_Index = nIndex;
|
|
|
|
|
|