cv::Vec operator= resolution behavior has changed (Bug #1306)


Added by Ethan Rublee over 13 years ago. Updated over 13 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:core
Target version:-
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

Here is the compile test

#include <opencv2/core/core.hpp>

/*
$ svn info
Path: .
URL: https://code.ros.org/svn/opencv/branches/2.3/opencv
Repository Root: https://code.ros.org/svn/opencv
Repository UUID: 73c94f0f-984f-4a5f-82bc-2d8db8d8ee08
Revision: 6487
Node Kind: directory
Schedule: normal
Last Changed Author: vp153
Last Changed Rev: 6484
Last Changed Date: 2011-08-14 12:43:59 -0700 (Sun, 14 Aug 2011)
*/
namespace ipa_Utils{
  cv::Vec3f [[GrayColorMap]](double value, double min,double max)
  {
      return cv::Vec3f(value,min,max);
  }
}

int main()
{
    cv::Mat hsvImage;
    int i =0,j= 0;
    cv::Vec3f a;

    //these compile
    cv::Vec3b b = a;
    hsvImage.at<cv::Vec3f>(i,j) = ipa_Utils::GrayColorMap(i,0,1);
    hsvImage.at<cv::Vec3b>(i,j) = cv::Vec3b(ipa_Utils::GrayColorMap(i,0,1));

    //these don't
    b = cv::Vec3f(1,0,0);
    cv::Vec3b c; 
    c = cv::Vec3f(0,0,1);
    hsvImage.at<cv::Vec3b>(i,j) = ipa_Utils::GrayColorMap(i,0,1);
    hsvImage.at<cv::Vec3b>(i,j) = a;
    hsvImage.at<cv::Vec3b>(i,j) = cv::Vec3f(1,2,3);
    return 0;
}

errors:

/home/erublee/opencv_release/opencv2.3/testy/vec_ops.cpp:35:24: error: ambiguous overload for ‘operator=’ in ‘b = cv::Vec<float, 3>(1.0e+0f, 0.0f, 0.0f)’
/home/erublee/opencv_release/opencv2.3/modules/core/include/opencv2/core/operations.hpp:1043:15: note: candidates are: cv::Vec<_Tp, cn>& cv::Vec<_Tp, cn>::operator=(const cv::Matx<_Tp, m, 1>&) [with _Tp = unsigned char, int cn = 3]
/home/erublee/opencv_release/opencv2.3/modules/core/include/opencv2/core/core.hpp:574:1: note:                 cv::Vec<unsigned char, 3>& cv::Vec<unsigned char, 3>::operator=(const cv::Vec<unsigned char, 3>&)
/home/erublee/opencv_release/opencv2.3/testy/vec_ops.cpp:37:24: error: ambiguous overload for ‘operator=’ in ‘c = cv::Vec<float, 3>(0.0f, 0.0f, 1.0e+0f)’
/home/erublee/opencv_release/opencv2.3/modules/core/include/opencv2/core/operations.hpp:1043:15: note: candidates are: cv::Vec<_Tp, cn>& cv::Vec<_Tp, cn>::operator=(const cv::Matx<_Tp, m, 1>&) [with _Tp = unsigned char, int cn = 3]
/home/erublee/opencv_release/opencv2.3/modules/core/include/opencv2/core/core.hpp:574:1: note:                 cv::Vec<unsigned char, 3>& cv::Vec<unsigned char, 3>::operator=(const cv::Vec<unsigned char, 3>&)
/home/erublee/opencv_release/opencv2.3/testy/vec_ops.cpp:38:64: error: ambiguous overload for ‘operator=’ in ‘hsvImage.cv::Mat::at [with _Tp = cv::Vec<unsigned char, 3>](i, j) = ipa_Utils::GrayColorMap(double, double, double)(0.0, 1.0e+0)’
/home/erublee/opencv_release/opencv2.3/modules/core/include/opencv2/core/operations.hpp:1043:15: note: candidates are: cv::Vec<_Tp, cn>& cv::Vec<_Tp, cn>::operator=(const cv::Matx<_Tp, m, 1>&) [with _Tp = unsigned char, int cn = 3]
/home/erublee/opencv_release/opencv2.3/modules/core/include/opencv2/core/core.hpp:574:1: note:                 cv::Vec<unsigned char, 3>& cv::Vec<unsigned char, 3>::operator=(const cv::Vec<unsigned char, 3>&)
/home/erublee/opencv_release/opencv2.3/testy/vec_ops.cpp:39:35: error: ambiguous overload for ‘operator=’ in ‘hsvImage.cv::Mat::at [with _Tp = cv::Vec<unsigned char, 3>](i, j) = a’
/home/erublee/opencv_release/opencv2.3/modules/core/include/opencv2/core/operations.hpp:1043:15: note: candidates are: cv::Vec<_Tp, cn>& cv::Vec<_Tp, cn>::operator=(const cv::Matx<_Tp, m, 1>&) [with _Tp = unsigned char, int cn = 3]
/home/erublee/opencv_release/opencv2.3/modules/core/include/opencv2/core/core.hpp:574:1: note:                 cv::Vec<unsigned char, 3>& cv::Vec<unsigned char, 3>::operator=(const cv::Vec<unsigned char, 3>&)
/home/erublee/opencv_release/opencv2.3/testy/vec_ops.cpp:40:50: error: ambiguous overload for ‘operator=’ in ‘hsvImage.cv::Mat::at [with _Tp = cv::Vec<unsigned char, 3>](i, j) = cv::Vec<float, 3>(1.0e+0f, 2.0e+0f, 3.0e+0f)’
/home/erublee/opencv_release/opencv2.3/modules/core/include/opencv2/core/operations.hpp:1043:15: note: candidates are: cv::Vec<_Tp, cn>& cv::Vec<_Tp, cn>::operator=(const cv::Matx<_Tp, m, 1>&) [with _Tp = unsigned char, int cn = 3]
/home/erublee/opencv_release/opencv2.3/modules/core/include/opencv2/core/core.hpp:574:1: note:                 cv::Vec<unsigned char, 3>& cv::Vec<unsigned char, 3>::operator=(const cv::Vec<unsigned char, 3>&)

These operators with implicit casts are important as client code depends on them compiling properly.


Associated revisions

Revision 41a35c3c
Added by Vadim Pisarevsky over 13 years ago

fixed bug #1306 (Vec assignment)

Revision fba70ca1
Added by Vadim Pisarevsky over 13 years ago

fixed bug #1306 (Vec assignment); added tests for Vec & Matx multiplication

Revision 1a7c2eef
Added by Roman Donchenko over 11 years ago

Merge pull request #1306 from jet47:gpu-bitwize-fix

History

Updated by Vadim Pisarevsky over 13 years ago

fixed in r6506

  • Status changed from Open to Done
  • (deleted custom field) set to fixed

Also available in: Atom PDF