This is function to get the color from a given Mat image,
string getColorFromPx(Mat *src, uint16_t x, uint16_t y){
Point pt = Point(x, y);
//Mat img = (*src).clone();
Vec3b& levelPxImg = imgHSV.at(y, x);
if ((levelPxImg[0] != NULL) && (levelPxImg[1] != NULL) && (levelPxImg[2] != NULL)){
//H(openCV) / 2 = H (HSV_Real);
if (levelPxImg[0] > 170 && levelPxImg[0] < 180)
return "R";
else if (levelPxImg[0] > 107 && levelPxImg[0] < 122)
return "B";
else
return "xx";
}
}
the program can work for a period time after that it notify an error as below:
"
First-chance exception at 0x00007FF64C1C30A3 in OpenCVex1.exe: 0xC0000005: Access violation reading location 0x0000000000000018.
If there is a handler for this exception, the program may be safely continued.
"
and current breakpoint is halted at return line as below:
int compare(const _Elem *_Ptr) const
{// compare [0, _Mysize) with [_Ptr, )
_DEBUG_POINTER(_Ptr);
-------> return (compare(0, this->_Mysize, _Ptr, _Traits::length(_Ptr)));
}
(this function locate in VS/include/xstring file).
Please take a look and help me to show problem.
↧