Ask Your Question

Spark's profile - activity

2020-07-01 02:20:54 -0500 received badge  Famous Question (source)
2017-05-17 09:40:04 -0500 received badge  Notable Question (source)
2016-06-01 22:38:30 -0500 received badge  Popular Question (source)
2015-12-20 15:17:20 -0500 received badge  Nice Question (source)
2015-04-30 03:52:28 -0500 commented question How Many Images for Camera Calibration?

Have a look at these blogs, which is really useful for stereo calibration.

Number of images and orientation of chess board being captured matters a lot. It is recommended to capture as many as 30 to 40 images in different orientation and different distance to make calibration best.

2015-04-28 02:25:10 -0500 commented question background substraction and camera electronics

Yes, you are exactly right. This is due to auto gain and auto exposure property of camera. Try disabling AEC and AEC using some camera viewer application like amcap (windows) or cheese (linux) and try experimenting with different manual gain and exposure values suitable for your environment. Eager to see your results:-)

2015-04-28 02:20:34 -0500 commented question How to improve blob detection rate?
2015-04-28 02:15:57 -0500 commented question Android - How to display image/animation over camera?
2015-04-28 01:27:39 -0500 commented question Spotter Needed!
2015-04-28 01:11:12 -0500 answered a question Is HSV supposed to look extremely blotchy in opencv?

Yes, as kbarni said, this is expected due to the behavior of CCD and CMOS sensors. There will be considerable amount of noise being added to image (even though you don't wish for).

Here is the synthesized color sample shape image

Color Image

And their hue channel image

Hue Channel

In this synth image, there wont be any patches. Hope you are clear now.

2015-04-28 00:44:24 -0500 commented question Template matching giving incorrect location

It would be better to understand your issue if you post some sample images and results.

2015-03-24 07:22:30 -0500 received badge  Teacher (source)
2015-03-24 03:41:13 -0500 commented question please help-no errors but nor output...

@sandun: Please read before posting your questions. It looks like you dint get any output as you did not specified any argument to your application. argv is empty in your case, so imread fails and hence condition of src.empty satisfies. Put some messages in your code to debug where it break out.

2015-03-24 03:39:24 -0500 commented question Set frame resolution problem

Try using Amcap and see whether you are able to switch resolution with that application. If that works, then resolution switching should work with OpenCV as well. Link to download

2015-03-24 01:20:59 -0500 answered a question Unable to open raw image through opencv

Following code snippet would help to load raw image to OpenCV Mat structure and then you can do further processing like demosaicing or some detection algorithms.

Mat img;
FILE *fp = NULL;
char *imagedata = NULL;
int framesize = IMAGE_WIDTH * IMAGE_HEIGHT;

//Open raw Bayer image.
fp = fopen("filename.raw", "rb");

//Memory allocation for bayer image data buffer.
imagedata = (char*) malloc (sizeof(char) * framesize);

//Read image data and store in buffer.
fread(imagedata, sizeof(char), framesize, fp);

//Image dimension.
imageSize.height = IMAGE_WIDTH;
imageSize.width = IMAGE_HEIGHT;

//Create Opencv mat structure for image dimension. For 8 bit bayer, type should be CV_8UC1.

memcpy(, imagedata, framesize);



//Perform demosaicing process
cvtColor(img, RGBImage, CV_BayerBG2BGR);

Once color space is converted to BGR, further processing like edge detection or enhancement can be done. Hope this helps.

2015-03-24 00:00:12 -0500 received badge  Organizer (source)
2015-03-24 00:00:06 -0500 commented question Background color similar to object color - How isolate it?

Preprocessing of underwater images is explained in this paper -

2015-03-23 05:53:17 -0500 commented question Auto Cropping after bitwise application

@zms: Share your input image as well.

2015-03-23 05:48:30 -0500 commented question OpenCV Assertion Failed with Stitcher

Keep breakpoints in Visual studio and find which function creates assertion. Do some debugging on variable and its value. Then post your questions, so that others will know you have worked something and really need help.

2015-03-23 05:46:54 -0500 received badge  Critic (source)
2015-03-23 05:46:07 -0500 commented question i need code to pass a line at the centre center of two curved lines

@creative, mark answers if it was helpful

2015-03-23 05:45:46 -0500 commented question reading a sequence of files within a folder

@KansaiRobot, mark answers if it was helpful

2015-03-23 05:44:41 -0500 commented question How to find out image format retrieved via VideoCapture ?

@ganesh17, mark answers if it was helpful

2015-03-23 05:44:21 -0500 commented question How to find out image format retrieved via VideoCapture ?

As berak said, it is always 24 BPP format. It can either be 8-bit gray scale with padded 16 bit or can also be BGR color data. Depends on data stored in the video.

2015-03-23 05:39:51 -0500 answered a question reading a sequence of files within a folder

You can refer to OpenCV samples. Many samples use this such concept. Here is one from \opencv\sources\samples\cpp\stereo_calib.cpp.

  1. Create a text file with list of image names along with path to be processed.
  2. Following code opens the text file and prepares the list of file names.

    FILE* f = fopen("ImageList.txt", "r");
    vector<string> imagelist;
    for(int i = 0; ; i++)
    if(!fgets(buf, sizeof(buf)-3, f))
    size_t len = strlen(buf);
    while(len > 0 && isspace(buf[len-1]))
        buf[--len] = '\0';
    if(buf[0] == '#')
  3. Start accessing images by imread(imagelist[i])

2015-03-23 01:03:22 -0500 answered a question i need code to pass a line at the centre center of two curved lines

Assuming you have two curved lines running parallel to each other in your image, here is a suggestion to get the mid point between curved line.

  1. Threshold the image
  2. Find contour and its bounding rectangle for each curved line's contour.
  3. Get angle of its bounding rectangle.
  4. Bounding rectangle of both curved line must be same as it is parallel to each other. If the angle of bounding rect is 0 deg or 90 deg, subtract x coordinate of contour to get the mid point between parallel lines. If the angle of bounding rect is other than 0 deg or 90 deg, subtract y coordinate of contour.

Share your results with image samples.

2015-03-20 09:24:25 -0500 commented question Shape matching using fourier descriptor - Frequency domain

@juanmanpr: Shape context in OpenCV 3.0 works well with their samples. But produces poor result with image attached in my original post. The distance value calculated by Shape context is high for same type of object, but low for different object, and varies with same object.

2015-03-19 00:39:21 -0500 commented question i need code to pass a line at the centre center of two curved lines

Refer to for finding edges of arc, organize coordinates forming arc in a vector either clock wise or anticlockwise order.. find mid value of vector, which would be the center of arc.

2015-03-18 02:41:10 -0500 received badge  Enthusiast
2015-03-17 03:36:08 -0500 commented question Shape matching using fourier descriptor - Frequency domain

Looks promising, will try and update you the result of Shape context in OpenCV 3.0.

2015-03-17 03:35:37 -0500 commented answer Shape matching using fourier descriptor - Frequency domain

Yeah, number of points chosen plays very important role in matching. But for now I am using all the descriptor points (say, 625, 535 points for few object). I find minimum of two contours and match those points by finding distance between them.

2015-03-11 07:06:02 -0500 received badge  Student (source)
2015-03-11 02:38:21 -0500 received badge  Editor (source)
2015-03-09 09:36:10 -0500 asked a question Shape matching using fourier descriptor - Frequency domain

Hey algorithm enthusiast,

Here is an implementation I am trying to make it work for shape matching that is invariant to rotation, translation and scaling as per theory.

Reference Links

What is the process that I tried

  • Get RGB input image, convert to gray scale

  • Guassian Blur the image with 3x3 kernel and perform thresholding

  • Do some morphological operation to close the edges and find external contour of this thresholded image

  • Find the largest contour that forms the boundary of desired object. The returned contour points are in counter clock wise direction, so reverse it to make it clockwise order. (As explained in few papers)

  • Perform differential coding (current coordinate - next coordinate) for contour coordinates and save it as vector of new points. Convert this to two planes (one for x and another for y).

  • Perform DFT for these differential encoded contour points. Calculate Magnitude from result of DFT, discard DC coefficient and normalize other Fourier coefficients with first harmonic (this is done for scale invariancy).

  • Perform Euclidean distance for template image and input test image.

Stuck up with

The Euclidean distance calculated is coming same/closer for any test sample I give. Not sure where I do mistake. I do not find any sample implementation for frequency domain shape matching.

Please help in understanding any mistakes that is being done.

Sample image in recognition Knife Input

Plier Input

contour knife

contour plier


I am trying to perform rotation, scale and translation invariant shape matching using Fourier descriptor as proved in technical papers. I am making use of OpenCV 2.4.9 on Windows.

2015-03-09 03:17:29 -0500 commented question can anybody please help me how to count our face in face detection

Could you elaborate your task and edit you question? Do you want to count number of faces in a scene? or Do you want to count occurrence of your face from a video of specific duration? Be detail while posting question in order to provide better replies.

2015-03-06 05:45:50 -0500 received badge  Supporter (source)