C++ map with <cv::Mat, IplImage*> key-value format

asked 2013-01-11 03:11:09 -0500

manmedia gravatar image

Hello,

I am trying to create a key-value pair (keyed by Mat images and associated values are in IplImage*). The fraction of my code that does the job is as follows:

   std::map<cv::Mat, IplImage*> testObj;
   cv::Mat testMat = cv::Mat();
   IplImage* testIplImagePtr = new IplImage();

   testObj[testMat] = testIplImagePtr; // So that it either inserts or updates

This is giving me error "cannot convert from cv::MatExpr to bool". I cannot understand why this is making a problem. Is it because IplImage is used in the internal structure of cv::Mat class?

edit retag flag offensive close merge delete

Comments

2

std::map<Key, Value> requires bool operator < (Key, Key). There is no such operator for cv::Mat.

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2013-01-11 03:25:37 -0500 )edit

@VladislavVinogradov thanks for your quick answer! At least there is nothing screwed up from my end!...Do you think I can somehow use std::pair to do this job?

manmedia gravatar imagemanmedia ( 2013-01-11 05:18:14 -0500 )edit
1

No, you still need a comparison operator for your Mat. You could define one for yourself, but its behaviour is application-dependent.

SR gravatar imageSR ( 2013-01-11 09:44:02 -0500 )edit