C++ map with <cv::Mat, IplImage*> key-value format
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?
std::map<Key, Value> requires bool operator < (Key, Key). There is no such operator for cv::Mat.
@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?
No, you still need a comparison operator for your
Mat
. You could define one for yourself, but its behaviour is application-dependent.