2020-11-13 03:43:29 -0600 received badge ● Nice Question (source) 2019-05-10 12:44:33 -0600 received badge ● Good Answer (source) 2018-10-24 02:26:17 -0600 received badge ● Famous Question (source) 2018-09-13 15:35:19 -0600 received badge ● Notable Question (source) 2018-06-15 08:48:17 -0600 received badge ● Nice Answer (source) 2017-10-22 13:02:44 -0600 received badge ● Nice Question (source) 2017-08-10 07:09:25 -0600 received badge ● Famous Question (source) 2017-08-07 04:52:58 -0600 received badge ● Famous Question (source) 2017-04-01 16:45:24 -0600 received badge ● Famous Question (source) 2017-03-17 04:28:21 -0600 received badge ● Notable Question (source) 2017-02-06 07:27:26 -0600 received badge ● Popular Question (source) 2016-07-05 06:17:55 -0600 received badge ● Enthusiast 2016-07-04 04:12:18 -0600 received badge ● Nice Answer (source) 2016-07-04 03:25:01 -0600 answered a question mapping 2 document I would use binary threshold, morphology and contours to solve this problem. Step 1 : get the copy with signature cv::Mat const map_01 = cv::imread("map01.jpg");  Step 2 : blur the image and convert it to binary image cv::Mat binarize; cv::cvtColor(map_01, binarize, CV_BGR2GRAY); cv::GaussianBlur(map_01, map_01, {5,5}, 3,3); cv::threshold(binarize, binarize, 0, 255, cv::THRESH_BINARY_INV | cv::THRESH_OTSU);  Step 3 : Use morphology to remove small blobs and make text blobs more obvious auto mrect = cv::getStructuringElement(cv::MORPH_RECT, {3,3}); cv::erode(binarize, binarize, mrect); mrect = cv::getStructuringElement(cv::MORPH_RECT, {7,5}); cv::morphologyEx(binarize, binarize, cv::MORPH_DILATE, mrect, {-1,-1}, 7);  Step 4 : find contours and remove those with invalid aspect ratio std::vector> contours; cv::findContours(binarize.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); auto rit = std::remove_if(std::begin(contours), std::end(contours), [](auto const &ct) { auto const rect = cv::boundingRect(ct); return rect.height > rect.width; }); contours.erase(rit, std::end(contours));  Step 5 : Find the data of each rectangle for(auto const &ct : contours){ //get the information of each rect cv::Mat temp = map_01.clone(); std::cout< #include #include #include #include void computeHash(cv::Ptr algo) { cv::Mat const input = cv::imread("lena.png"); cv::Mat const target = cv::imread("lena_blur.png"); cv::Mat inHash; //hash of input image cv::Mat targetHash; //hash of target image //comupte hash of input and target algo->compute(input, inHash); algo->compute(target, targetHash); //Compare the similarity of inHash and targetHash //recommended thresholds are written in the header files //of every classes double const mismatch = algo->compare(inHash, targetHash); std::cout< A; A.push_back(0); A.push_back(1); A.push_back(2); A.push_back(3);  Suppose I want to make the matrix become 2 rows 2 cols like this [0, 1; 2, 3].How could I push the value into the column of A with type "float"? Edit : exception thrown A = A.reshape(1,2); //this line would crash in openCV 2.4.5 cv::Mat_ B = A.reshape(1, 2); //ok, wouldn't crash, but the buffer are different std::cout<<(B.data == A.data)<type() == mtype) in create, file /Users/yyyy/Downloads/opencv-2.4.5/modules/core/src/matrix.cpp, line 1345"* Don't know where is the error occur, should I treat this as a bug and report it? Edit 2 : unsafe codes? I found something interesting, in the class Mat there are a flag /*! includes several bit-fields: - the magic signature - continuity flag - depth - number of channels */ int flags;  The flags is int, that means the behavior of the sign bit may not work as the programmer expect. When we call reshape, the Mat will do some operation on the flag hdr.flags = (hdr.flags & ~CV_MAT_CN_MASK) | ((new_cn-1) << CV_CN_SHIFT);  And the function fixedType() and type() use the flags to check the type of Mat core/include/opencv2/core/mat.inl.hpp inline int Mat::type() const { return CV_MAT_TYPE(flags); }  modules/core/src/matrix.cpp bool _OutputArray::fixedType() const { return (flags & FIXED_TYPE) == FIXED_TYPE; }  2016-06-19 00:50:32 -0600 commented answer Smoke detection Sorry, theo2f, I cannot find a good enough solution to solve your problems, it is too hard to deal with jigger + moving camera for smoke detection. I will contact you after I found a good solution which could detect smoke on single frame. 2016-06-19 00:50:19 -0600 commented question Smoke detection It works on the video sets quite well, but it do not guarantee on other environments. Besides, this algorithms only work if your camera is stable 2016-04-29 08:22:49 -0600 received badge ● Popular Question (source) 2015-12-28 01:48:27 -0600 received badge ● Notable Question (source) 2015-12-06 13:17:37 -0600 received badge ● Notable Question (source) 2015-11-02 13:23:57 -0600 received badge ● Nice Question (source) 2015-11-02 13:23:50 -0600 received badge ● Notable Question (source) 2015-06-04 09:42:14 -0600 received badge ● Popular Question (source) 2015-04-26 19:33:00 -0600 received badge ● Popular Question (source) 2015-03-23 05:28:13 -0600 received badge ● Popular Question (source) 2014-12-09 13:59:04 -0600 marked best answer Create a layer for artificial neural network of openCV2 According to this blog, it create the labels as this way  cv::Mat layers = cv::Mat(4, 1, CV_32SC1); //create 4 layers layers.row(0) = cv::Scalar(2); //input layer accepts x and y layers.row(1) = cv::Scalar(10);//hidden layer layers.row(2) = cv::Scalar(15);//hidden layer layers.row(3) = cv::Scalar(1); //output layer returns 1 or -1  But in the book, it create the layers as following Mat layers(1,3,CV_32SC1); layers.at(0)= TrainData.cols; layers.at(1)= nlayers; layers.at(2)= numCharacters;  1 : The blog use rows to save the parameters but the book use cols to save the parameters.Are they the same thing?Do I have to change the way of writing, reading the xml according to the way of saving the parameters(any issues I do not mention have to take care)? 2 : What is the order of the layers?As I guess(uncertain) The feature numbers of each sample number of layers ~ Last(assume 4 == last in this case) - 1 Classes(The kinds of data want to classify. ex : '0', '1', ..., '9') 2014-12-09 13:57:13 -0600 marked best answer Where is the source codes of cv::getRectSubPix? I would like to study the source codes of cv::getRectSubPix, but I can't find it in the module imgproc, do anyone know where could I find the source codes?Thanks 2014-12-09 13:57:04 -0600 marked best answer Draw the lines detected by cv::HoughLines On this site(tutorial), it show us how to draw the lines detected by cv::HoughLines,but I can't understand how could it find out the Point between the lines.  for( size_t i = 0; i < lines.size(); i++ ) { float rho = lines[i][0], theta = lines[i][1]; Point pt1, pt2; double a = cos(theta), b = sin(theta); double x0 = a*rho, y0 = b*rho; pt1.x = cvRound(x0 + 1000*(-b)); //?? pt1.y = cvRound(y0 + 1000*(a)); //?? pt2.x = cvRound(x0 - 1000*(-b)); //?? pt2.y = cvRound(y0 - 1000*(a)); //?? line( cdst, pt1, pt2, Scalar(0,0,255), 3, CV_AA); }  Another codes from the openCV2 cookbook.I could understand why the codes from the cookbook work but it is more verbose. for(auto const &data : lines){ float const rho = data[0]; float const theta = data[1]; if((theta < PI/4. || theta > 3. * PI/4.)){ cv::Point pt1(rho / std::cos(theta), 0); cv::Point pt2( (rho - result.rows * std::sin(theta))/std::cos(theta), result.rows); cv::line(result, pt1, pt2, cv::Scalar(255), 1); }else if{ cv::Point pt1(0, rho / std::sin(theta)); cv::Point pt2(result.cols, (rho - result.cols * std::cos(theta))/std::sin(theta)); cv::line(result, pt1, pt2, cv::Scalar(255), 1); } }  2014-12-09 13:56:06 -0600 marked best answer Header files of sift in github Studying the source codes of sift but can't find out where is the header files.Every folder from github are not included the header files(declaration) of the sift. 2014-12-09 13:53:10 -0600 marked best answer Do we need to optimize matrix operation of cv::Mat? clean and easy to read, but this kind of operation may generate two temporary objects foreground_current = (frame_current_ - (1 - Beta_) * background_current_) / Beta_; //#1  Hard to read and verbose //can't alter the value of background_current background_current_.copyTo(temp_); temp_ *= 1 - Beta_; //can't use (Beta_ - 1) since it is negative frame_current_.copyTo(foreground_current_); foreground_current_ -= temp_; foreground_mask_ /= Beta_;  or write a for loop for it? //same as for loop OCV::transform_channels(frame_current_, background_current_, foreground_current_, [=](uchar fr, uchar bg) { return cv::saturate_cast((fr - (1 - Beta_) * bg) / Beta_); });  What I want to ask is, do openCV provide some optimization for operator overloading? With the help of expression template, it is possible to eliminate the temporary objects of #1. Do openCV2 support this kind of optimization?Thanks 2014-12-09 13:44:40 -0600 marked best answer Problem about the source codes of otsu-threshold The codes from the files thresh.cpp, the function name is getThreshVal_Otsu_8u if( std::min(q1,q2) < FLT_EPSILON || std::max(q1,q2) > 1. - FLT_EPSILON ) continue;  As far as I know, q1 + q2 = 1--(1) q1 = 1 - q2--(2) q2 = 1 - q1--(3)  That means if q1 < FLT_EPSILON  then 1 - q1 will satisfy 1 - q1 > 1 - FLT_EPSILON  In other words, if std::min(q1,q2) < FLT_EPSILON, then std::max(q1,q2) > 1. - FLT_EPSILON should satisfy too.So why do the codes need to do double check? Why don't just use if( std::min(q1,q2) < FLT_EPSILON) continue;  2014-12-09 13:08:58 -0600 marked best answer c++ api of LogPolar transform of openCV Do openCV2 provide a c++ api for LogPolar transform logpolar describe in this page?Can't find any api corresponding to this function.I search the api from the openCV doc and google but can't find anything related to c++ api. 2014-10-31 12:32:28 -0600 marked best answer openCV will drop C API support soon From the pdf of ICVS2013(http://opencv.org/icvs2013.html), it say openCV will drop C API support soon.Do anyone know the details?Drop C API support means they will not develop any new api for C or they will discards all of the C API in the future? I am a fans of openCV2 and do not like C API of openCV1, too verbose and no performance gain by using it, if openCV will discards all of the C API, I would have more reasons to push my colleagues move to c++ API and increase the chances to say goodbye to C API. 2014-06-28 06:52:40 -0600 received badge ● Nice Question (source) 2014-06-20 01:46:23 -0600 marked best answer Create a memory continuous cv::Mat, any api could do that? cv::Mat dst(src.size(), src.type());  I want to make sure the memory of the dst is continuous(without padding), how could I do that? The most easiest answer is call the reshape after creation. dst.reshape(0);  But how could I make sure it is continuous when construct?