Ask Your Question

Mohammad Etemaddar's profile - activity

2015-01-26 22:48:33 -0500 commented question vector, copy and add to

You are right, I repaired the code. and it's now corrected by clone() method.

2015-01-26 00:51:24 -0500 answered a question Is there a direct way to print a Mat on one line ?

Maybe you need OpenCV print formats:

2015-01-26 00:24:38 -0500 asked a question vector, copy and add to

When I create a vector and add new calculated Mat to it using for loop, it will add the same reference as my Mat has same name.

for example:

vector<Mat> hists;
for (int row = 0 ; row < 2 ; row++)
 for (int col = 0 ; col < 4 ; col++)
  hist_mat.set_roi(row , col);;
  cout << hist_mat.hist_h << endl;

for (int i = 0 ; i < 8 ; i++)
  cout << hists[i] << endl;

although the first cout has different lines, The second "cout" will have same lines (The last added element); Because all vector elements has same reference. What is a good way to copy and add to the vector?

2015-01-09 04:00:39 -0500 commented question Tool for cropping positive samples

Your English is good, But would you mind give an example of pictures, and your need in output?

2015-01-09 03:57:30 -0500 received badge  Autobiographer
2015-01-08 14:18:50 -0500 received badge  Nice Answer (source)
2015-01-08 08:32:16 -0500 received badge  Teacher (source)
2015-01-08 07:19:11 -0500 received badge  Editor (source)
2015-01-08 07:18:26 -0500 answered a question best development platform

If you do not want IDE to run, You can use gcc, cmake and make. It is explained in documentation. I use this method. Works fine. I like it, Because it's simpler to understand than other ways for me. You can use any editor you like. I use both vim and sublime on Linux.

Of course as you may know, OpenCV serves python, Java, C# and other. If you use python, then you do not need compiler, Just python and editor :) If you use IDE, It would be more pleasant and more easy to code.

2015-01-08 07:11:52 -0500 commented question Extract each label after Connected Component Labeling

It would be appreciated if you explain your code a little. Thanks.

2015-01-08 07:09:24 -0500 received badge  Supporter (source)
2015-01-08 07:06:53 -0500 asked a question Calculate Histogram of Hue

I want to compare my object by objects in database. So I decided to calculate their histogram of Hue and then compare my new Histogram by previous pictures. I decided to calculate Hue's histogram, Because I thought that it has low dependency to light.

This is my code: I have split the HSV picture and then I think that the first element of vector will have the Hue value. But it is surprising that I get the second line of output for every picture on 1080.

First I want to know if this code has written true for the purpose and then It would be appreciated if you help me by improving my code in both algorithm and programming manner.

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

class mycalchist
    Mat src_hsv, src_h, hist_h;
    void setHistSize(int);
    void run();
    int histSize;

    float range[2];
    const float* histRange;
    bool uniform; bool accumulate;
    vector<Mat> src_hsv_vector;

int main(int argc, char** argv)
    Mat src;
    if (argc > 1)

        src = imread(argv[1]);
        if (!
            return -1;
        cout << "Usage: " << argv[0] << " <image file name>" << endl;

    mycalchist image(src);;

    for (int i=0;i<image.histSize; i++)
        cout <<<float>(0,i) << endl;
    return 0;


mycalchist::mycalchist(Mat src)
    split (this->src_hsv,src_hsv_vector);
    this->src_h = src_hsv_vector[0];
    this->range[0] = 0;
    this->range[1] = 256;
    this->histRange = {this->range};
    this->uniform = true;
    this->accumulate = false;
    this->histSize = 10;

void mycalchist::run()
    calcHist( &this->src_h, 1, 0, Mat(), this->hist_h, 1, &this->histSize, &this->histRange, this->uniform, this->accumulate );
    normalize(this->hist_h, this->hist_h, 0, this->src_h.rows, NORM_MINMAX, -1, Mat() );