accessing to a Matrix cell
Hello
I am implementing some filters on my image, but the point is that when I use abs() and then try to imshow my result image, it's all black. the harris_result is a cv::Mat *harris_result.
cv::MatExpr x = cv::abs(re); harris_results = &x.a;//convert cv::MatExpr to cv::Mat and then when I want to print the content of harris_result
std::cout<<harris_results->at<uchar>(10,100)<<std::endl; harris_result="" is="" a="" cv::mat="" *harris_result<="" p="">
there is no error, but while debugging at this line it stops working.
I appreciate some help
Thanks
it probably needs a bit more code. where is harris_result coming from ?
also, you could try to format your code nicely (mark it , and press the 10101 button)
these code are in a function that returns harris_results,harris_features_def and a long value. that's why harris_result is a pointer. and I just need to access each cell . long harris(cv::Mat derivX, cv::Mat derivY,int is_first,cv::Mat *harris_results,cv::Mat *harris_features_def) and I just need to access each cell . as the below code is not working, just for test I tried to cout std::cout<<harris_results->at<uchar>(10,100)<<std::endl; to see is it's reading teh value, but it does not for (i=6 ; i < harris_results->rows; i++) for (j=6 ; j < harris_results->cols; j++) if ((harris_results->at<uchar>(i, j) > Harris_TH) && (i>5) && (i<1020) && (j>5) && (j<1020)) { harris_features[t][1]=harris_results->at<uchar>(i, j); harris_features[t][2]=i;...
please, again, that should go into your question (code in comments is a PITA)
also, where does harris_result come from ? e.g. cornerHarris outputs float result Mats. you might access harris_results in a wrong way.
last, but not least, - do not pass cv::Mat as a Pointer, but as a reference. those things are refcounted internally (aka smart pointer) and you'll wreck havoc on that by passing pointers