Ask Your Question
0

unable to set saturation in grayworld white balancing of opencv_extra module

asked 2018-12-31 01:09:55 -0500

nobot gravatar image

virtual void cv::xphoto::GrayworldWB::setSaturationThreshold ( float val ) ;

without this function, the below code is having no issues, but when i am trying to get or set the saturation level it is giving the error:cannot call member function ‘virtual void cv::xphoto::GrayworldWB::setSaturationThreshold(float)’ without object, what is the correct way to call the function??

int main(int argc, const char **argv)

{

Mat src,resized,res;

src = imread("/home/u-16i/Pictures/wp/beach_flowers-wallpaper-1440x900.jpg");
if (src.empty())
{
    printf("Cannot read image file");
    return -1;
}
resize(src, resized, Size(), .49, 0.49, CV_INTER_AREA);
imshow("b4 white balance", resized);

Ptr<xphoto::GrayworldWB> wb =xphoto::createGrayworldWB();
xphoto::GrayworldWB::setSaturationThreshold(0.5);//error: cannot call member function ‘virtual void cv::xphoto::GrayworldWB::setSaturationThreshold(float)’ without object
wb->balanceWhite(resized, res);

    imshow("after white balance", res);

waitKey(0);
return 0;

}

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2018-12-31 01:16:08 -0500

berak gravatar image

you're trying to use it like a static function, but you need to call it on the actual instance, like:

wb->setSaturationThreshold(0.5);
edit flag offensive delete link more

Comments

1

thanks, it is solved

nobot gravatar imagenobot ( 2018-12-31 02:47:54 -0500 )edit
1

but if I use UMat , it is giving exception error, any reason??` {

Mat src_mat;     UMat src_umat,resized,res;
float inputMIN= 0.1f, inputMAX= 0.1f, outputMIN= 0.1f, outputMAX= 0.1f, pcent_topbybottom =0.1f;
src_mat = imread("/home/u-16i/Pictures/wp/beach_flowers-wallpaper-1440x900.jpg");
if (src_mat.empty()) {
    printf("Cannot read image file");    return -1;}
src_mat.copyTo(src_umat);
    resize(src_umat, resized, Size(), .29, 0.29, CV_INTER_AREA);  imshow("b4 white balance", resized);

Ptr<xphoto::SimpleWB> wb =xphoto::createSimpleWB();        inputMAX=wb->getInputMax();
cout<<"inputMAX-->\t"<<inputMAX<<endl;
wb->setP(4.2);


wb->balanceWhite(resized, res);
imshow("after white balance", res);

waitKey(0);
return 0;

}

nobot gravatar imagenobot ( 2018-12-31 06:44:58 -0500 )edit
1

it is showing error terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(3.4.2) /home/u-16i/softwares/opencv/opencv/modules/core/src/matrix_wrap.cpp:1731: error: (-215:Assertion failed) k == MAT in function 'getMatRef'

nobot gravatar imagenobot ( 2018-12-31 06:46:55 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-12-31 01:09:55 -0500

Seen: 79 times

Last updated: Dec 31 '18