Ask Your Question

isarandi's profile - activity

2015-08-13 08:12:09 -0500 received badge  Enlightened (source)
2015-08-13 08:12:09 -0500 received badge  Good Answer (source)
2015-03-31 14:25:54 -0500 commented question What is a stage in cascade/haar training
2014-05-26 06:17:04 -0500 commented question BackgroundSubstract

@Junglee What is your application about, what is your goal? How long did you wait for it to disappear?

2014-05-23 19:13:32 -0500 received badge  Citizen Patrol (source)
2014-05-23 12:09:43 -0500 commented question BackgroundSubstract

You probably need to wait until the background model adapts to the new appearance there. Or you may want to use a different background modeling approach. Perhaps a simple thresholded absolute difference with an empty scene is enough.

2014-05-23 12:05:57 -0500 answered a question How do I capture, process and output an image in RGB (not BGR)?

imshow expects BGR images. If the result is messed up, I think the problem is with the VideoCapture. Maybe VideoCapture gives RGB? Anyway you can use cv::cvtColor to convert between BGR and RGB.

cv::cvtColor(rgbMat, bgrMat, cv::COLOR_RGB2BGR);
cv::cvtColor(bgrMat, rgbMat, cv::COLOR_BGR2RGB);

Disclaimer: I only have experience with OpenCV on desktop.

2014-05-23 11:59:43 -0500 answered a question Eliminating small blobs leaving bigger ones intact

Connected Component Labeling may be a good solution here. Take a look at this implementation.

2014-05-23 11:51:00 -0500 commented question Difference of frame size and cv::Mat size

Maybe the video is compressed?

2014-05-16 17:04:40 -0500 commented question Undistortion of image returns nothing

I don't know the solution but why don't you write a function instead of copying code and suffixing variable names? Also in the line h1, w1 = img.shape[:2] you forgot to change img to img1.

2014-05-14 16:05:28 -0500 received badge  Supporter (source)
2014-05-14 02:20:51 -0500 received badge  Nice Answer (source)
2014-05-13 14:56:05 -0500 received badge  Teacher (source)
2014-05-13 12:06:17 -0500 answered a question How to cut an image in small images with opencv !!!

You can extract rectangular regions from a Mat.

cv::Mat bigImage = cv::Mat::zeros(cv::Size(660,350));
cv::Mat smallImage = cv::Mat(bigImage, cv::Rect(0,0,110,70));

cv::Rect takes the x, y, width, height as constructor parameters.

Note that this will not copy the image data, it just creates another wrapper to the same image data. If you need data copy, use

cv::Mat smallImage = cv::Mat(bigImage, cv::Rect(0,0,110,70)).clone();

Now if you need to extract multiple such image parts, essentially slicing your image with a grid, you can create a for loop as follows.

cv::Size smallSize(110,70);
std::vector<Mat> smallImages;

for (int y = 0; y < bigImage.rows; y += smallSize.height)
    for (int x = 0; x < bigImage.cols; x += smallSize.width)
        cv::Rect rect =  cv::Rect(x,y, smallSize.width, smallSize.height);
        smallImages.push_back(cv::Mat(bigImage, rect));

Here I assumed that the size of the bigImage is an integer multiple of the size of the desired small images.

2014-05-13 05:43:46 -0500 commented question Calc Grain of Image? (Difference between two Pictures)

This is a texture problem. There are many texture descriptors that could be used here. It really depends on what the percentage should represent and what you want to do with it later. Maybe the simple approach of calculating the contrast of the image or the variance of the pixel values or the gradient strengths could work.

2014-05-13 05:34:44 -0500 commented question double to mat

Mat can contain doubles as matrix elements. Google for OpenCV Basic Structures and you will find a page about Mat. Do you already have another double matrix class that you are trying to convert to Mat? Please be more specific. You are more likely to find help if you ask in a clear way.

2014-05-13 05:29:03 -0500 received badge  Editor (source)
2014-05-13 05:25:34 -0500 commented question Calc Grain of Image? (Difference between two Pictures)

Difference between what? How do you define the 'grain' of an image? Percentage of what? Are you using some kind of texture descriptors? Or is your question about choosing such texture descriptors?

2014-05-13 05:21:30 -0500 commented question problem of application of the algorithm to the video k-means

Please spend more time to formulate your questions more clearly. Otherwise you will have a bad experience here and not know why. People will be helpful but first you need to put some effort into asking your question. What is your goal? You can even upload example images.

2014-05-13 05:15:52 -0500 received badge  Critic (source)
2014-05-11 09:28:20 -0500 received badge  Student (source)
2014-05-10 10:38:41 -0500 asked a question Mat::col() to std::vector bug?

I'm trying to convert a column of a cv::Mat to an std::vector. Mat has such a type conversion operator but it doesn't do what I would expect. Let's create a 10 by 2 matrix and add ascending elements in row major order starting with 1.

cv::Mat m(10,2, CV_64F);

int num = 1;
for (int row = 0; row < m.rows; ++row)
    for (int col = 0; col < m.cols; ++col)
    {<double>(row,col) = (double)(num++);

std::vector<double> v = m.col(0);
cout << v[0] << endl; //outputs 1, OK
cout << v[1] << endl; //outputs 0 instead of 3
cout << v[2] << endl; //outputs 0 instead of 5, etc.

However, if I replace the line

std::vector<double> v = m.col(0);


std::vector<double> v = m.col(0).clone();

then it works as expected and outputs lines 1, 3, 5. With some other matrix sizes (e.g. 120x2) it even crashes at memcpy (inside cv::Mat::copyTo(cv::OutputArray)) with segmentation fault or at vector destruction.

I'm using OpenCV 2.4.8 Debug build, GCC 4.8.2, Ubuntu 14.04 LTS 64-bit.

2014-05-04 10:02:49 -0500 asked a question How to step into OpenCV source when debugging in Qt Creator?

I'm trying to step into OpenCV source files while debugging. I'm using Qt Creator on Ubuntu 14.04 64-bit with GDB and GCC. OpenCV version 2.4.8. I built OpenCV from source using CMAKE_BUILD_TYPE=Debug and later also with ENABLE_PROFILING just to make sure. Still, I cannot jump into the OpenCV source when I'm debugging. Do I need to set something in the .pro project file? Or maybe set up some Source Mapping in Qt Creator settings? Thanks!