Ask Your Question

Abhishek Kumar Annamraju's profile - activity

2015-02-27 16:05:54 -0500 commented question (OpenCV/C++) Image Rectitication/Transformation

Have a look at this: calibration

2015-02-25 22:20:51 -0500 answered a question Problems using Stitcher::stich

The reason you are getting the error, or rather no result image is created, in your case small pixel sized black image is due to the fact that stitcher parameters are created with default values in parameters. Here the resolution acceptance ratio is set to 0.6 as default, but you require it to be flexible,

That is why, just after the line

Stitcher stitcher = Stitcher::createDefault(try_use_gpu);

add these

stitcher.setRegistrationResol(-1); /// 0.6
stitcher.setSeamEstimationResol(-1);   /// 0.1
stitcher.setCompositingResol(-1);   //1
stitcher.setPanoConfidenceThresh(-1);   //1
stitcher.setWaveCorrection(true);
stitcher.setWaveCorrectKind(detail::WAVE_CORRECT_HORIZ);

I hope this will help you out.

2015-02-25 21:38:26 -0500 answered a question Problem when stitching images using stitcher module

Hello,

The reason you are getting the error, or rather no result image is created, is due to the fact that stitcher parameters are created with default values in parameters.

That is why, just after the line

Stitcher stitcher = Stitcher::createDefault(try_use_gpu);

add these

stitcher.setRegistrationResol(-1); /// 0.6
stitcher.setSeamEstimationResol(-1);   /// 0.1
stitcher.setCompositingResol(-1);   //1
stitcher.setPanoConfidenceThresh(-1);   //1
stitcher.setWaveCorrection(true);
stitcher.setWaveCorrectKind(detail::WAVE_CORRECT_HORIZ);

I hope this will help you out.

2015-01-08 06:50:16 -0500 received badge  Enthusiast
2014-12-09 14:01:12 -0500 marked best answer Split CIE-LUV color space channels

Hello friends,

I am trying to compute the three channels in an image which is in CIE-LUV color space for feature extraction.Basically I am trying to split the color channels as we do in case of RGB images.So I want to know whether this splitting is same as we do in case of rgb images or is there some other efficient way.Please help me out.

Thanks in advance. :)

2014-10-21 05:00:56 -0500 commented question how to solve occlusion problem in multiple object?

@coco if I find something in this I will revert back

2014-10-19 02:31:45 -0500 received badge  Organizer (source)
2014-10-17 06:44:40 -0500 commented question how to solve occlusion problem in multiple object?

@thdrksdfthmn I have trained many xml files for the same object/dataset using variations in parameters and then tried to use the best ones to detect the cars in most efficient way.

2014-10-17 02:39:39 -0500 commented question how to solve occlusion problem in multiple object?

@coco and @thdrksdfthmn Make sure you fetch all the other possibilities you have other than traincascade, try going up for advanced feature extractors like Weber Descriptors,SIFT, etc. Traincascade is a very tedious process and unless combined with parallel computing it is a very long job, even the results are uncertain as you need to play with the training parameters a lot. Look for SVM training also if you have to go up for machine learning. Anyway here's a tutorial from my blog for traincascade : http://abhishek4273.com/2014/03/16/traincascade-and-car-detection-using-opencv/

2014-10-10 03:14:13 -0500 commented question how to solve occlusion problem in multiple object?
2014-10-09 01:04:27 -0500 commented question OpenCV tries to allocate a crazy amount of memory

I tried reading the image and its working fine for me, no errors. Could you be more specific as to what code are you using? If you are using IplImage I would strongly suggest you to go up with Mat image container. IplImage doesn't release the memory, but Mat is kind of a smart pointer, it allocates only when the image is being called and releases it immediately.

2014-10-09 00:48:28 -0500 commented question Install opencv in Ubuntu 64 bits
2014-10-08 06:15:42 -0500 commented question traincascade seg fault

From mode ALL revert back to mode BASIC

2014-10-08 03:23:54 -0500 commented question traincascade seg fault

I think the fault is because it is unable to fetch images, make sure the path to negatives, positives and samples is correct.

2014-10-08 03:21:29 -0500 commented question Compiling error in VS 2010 Express - OpenCV 2.4.8
2014-10-07 11:50:29 -0500 commented question Cannot computer hog descriptors

This link might help you out if there is some error with your code and not the compilation method : http://feelmare.blogspot.in/2014/04/example-source-code-of-extract-hog.html

2014-10-07 11:41:43 -0500 commented question How can I change the norm used by cv::FlannBasedMatcher?

Basically there are these norm types defined in the cv2.NORM_L2,cv2.NORM_L1,cv2.NORM_HAMMING,cv2.NORM_HAMMING2. This documentation may help you : http://docs.opencv.org/trunk/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html

2014-09-04 06:38:14 -0500 received badge  Teacher (source)
2014-08-10 04:18:55 -0500 commented question opencv_traincascade error : _img.rows * _img.cols == vecSize

What I believe is that opencv_traincascade has no parameter named -sampleWidth, I guess we mention it by -w, same goes with the height. Please try this, if the problem still persists, do ping me up here.

2014-08-09 17:46:02 -0500 commented question TrainCascade stuck on getting new negatives

@mada it means that if the stage is 9th and maxFalseAlarmRate is 0.5,the the probability is 9^0.5 = 3 ,which is not possible, since probability > 1. Please help me.

2014-08-09 02:51:01 -0500 asked a question Haar training is using libraries from previously installed opencv,Not the newly installed 2.4.8

Hello Friends,

I was training my classifier using haar-training. I have opencv-2.4.8 installed which I upgraded from 2.0.0 on one of my college's PC.

When I type "pkg-config --modversion opencv" the output is 2.4.8

Now while training whenever error comes, it refers to for example build/Opencv-2.0.0/haartraining.cpp. So basically it refers to Opencv-2.0.0.

I even tried Traincascade(Haar one) but there are errors which refer to OpenCV-2.0.0.

Clearing it before-hand, the same method for training works perfectly for my laptop,which has opencv-2.4.6 . I had to shift it to college's computer because of heating problem of laptop and greater availability of RAM in college's PC.

Any help is highly appreciated. :)

2014-08-02 14:14:17 -0500 commented question number detection in opencv

See you could go for machine learning using haarcascades (http://docs.opencv.org/doc/user_guide/ug_traincascade.html) or SVM (http://docs.opencv.org/doc/tutorials/ml/introduction_to_svm/introduction_to_svm.html#introduction-to-support-vector-machines)

Another way is you go for detecting features for every particular number and then making the system learn it.Obviously its not that easy as it sounds,you have to go up researching on this. Search up for implemented projects on different platforms like Matlab etc and then implement it on OpenCV.

2014-07-31 03:19:53 -0500 commented question How to create our own Haarcascade.xml.

@Punith first follow what Steven is saying, he has nice experience in this.

2014-07-31 02:20:44 -0500 commented question How to create our own Haarcascade.xml.

@steven will consider your comment and will update my tutorial on haar-cascades :)

2014-07-31 02:05:52 -0500 commented question How to create our own Haarcascade.xml.

@steven ..... The merge is being used so that greater number of samples can be prepared. The opencv_createsamples function when applied on a set of images provides only the same number of samples as the number of images in the training. But when applied on single image multiple samples can be generated. So I have created a perl file that takes images one by one and then applies the create samples function. And the merging code to pass on every vec file to a single one.

2014-07-29 13:06:20 -0500 commented question Need dataset for: car, truck, bus, motorbikes

For car dataset go for UIUC car database: http://cogcomp.cs.illinois.edu/Data/Car/

2014-07-29 08:56:08 -0500 received badge  Student (source)
2014-07-29 01:55:08 -0500 asked a question SVM and Hog Features: how to use them in a combined manner for a precise object detection

Hello Forum members,

I have worked a lot with haar-training and train-cascade to create cascade xml files.But these methods are time consuming and most of the times get stuck.

Currently I am researching on object training and detection using Support vector machine(SVM). I have 5781 images of which 1761 are positives. Firstly I did the training simply on the basis of intensity values. But the results were simply horrible. The trained XML file when used was just able to detect positives and negatives from the training image set only. On any other image the result was false positive.

Now I went for passing up Hog-features detected from every training image into the training. The results have improved a lot.But still there is a bigger scope of improvement. Now the SVM detector when passed through this trained cascade detects object in images other than training images BUT only of the same format of the image.

Please help me up in finding a robust solution to use this SVM to detect objects. I am posting the code for training here below, please help me in modifying the parameters so that the training goes robust.

Thank you in advance :)

CODE:

#include "cv.h" 
#include "highgui.h"
#include "ml.h"
#include <stdio.h>
#include <iostream>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>
#include <sstream>
#include <string>
#include <cstring>
#include <stdlib.h>

using namespace cv; 
using namespace std;

void reverse(char str[], int length)
{
    int start = 0;
    int end = length -1;
    while (start < end)
    {
        swap(*(str+start), *(str+end));
        start++;
        end--;
    }
}

// Implementation of itoa()
char* itoa(int num, char* str, int base)
{
    int i = 0;
    bool isNegative = false;

    /* Handle 0 explicitely, otherwise empty string is printed for 0 */
    if (num == 0)
    {
        str[i++] = '0';
        str[i] = '\0';
        return str;
    }

    // In standard itoa(), negative numbers are handled only with
    // base 10. Otherwise numbers are considered unsigned.
    if (num < 0 && base == 10)
    {
        isNegative = true;
        num = -num;
    }

    // Process individual digits
    while (num != 0)
    {
        int rem = num % base;
        str[i++] = (rem > 9)? (rem-10) + 'a' : rem + '0';
        num = num/base;
    }

    // If number is negative, append '-'
    if (isNegative)
        str[i++] = '-';

    str[i] = '\0'; // Append string terminator

    // Reverse the string
    reverse(str, i);

    return str;
}

int main()  
{  
 //variables  

 char FirstFileName[100]="train/";                  //the location of the training images.Both positives and negatives must be in same folder
 char lastname[100] = ".JPG";                       //type of the images
 float data[1000][3];                               
 int FileNum=5781;                                  //Number of images(Positives + negatives)

 vector< vector < float> > v_descriptorsValues;  
 vector< vector < Point> > v_locations;  
 Mat Hogfeat; 
 float labelsMat[5781];                              //Length of array must be equal to number of training images

 int img_area = 1*61236;                    //61236 is the number of features detected. Make sure you mention the number of features detected.
 Mat training_mat(FileNum,img_area,CV_32FC1);

//  Mat training_mat(4, 2, CV_32FC1, trainingData);
 for(int i=1; i<=FileNum; i++)  
 {  

  char FullFileName[100] = "";
  char number[100] = "";
  strcat(FullFileName,FirstFileName);
    itoa(i,number,10);
    strcat(FullFileName,number);
    strcat(FullFileName,lastname);

  //read ...
(more)
2014-07-29 01:27:22 -0500 commented question HaarTraining cvSave exception

The issue might be related to this. When you are providing the haar-training command with a feature named "-data PATH" just make sure that the folder in which the xml file will be stored is created by you manually.

2014-07-29 01:20:19 -0500 received badge  Commentator
2014-07-29 01:20:19 -0500 commented question how to start gesture programming in opencv

Hi Nitish, You must have a fair knowledge of: 1) GUI interfacing with OpenCV 2) Feature extractions to point out fingers and keys 3) Machine learning part(cascades) with OpenCV to learn and detect gestures 4) You must get well versed with the libraries and various functions in the OpenCV cpp api

It will be really useful for the forum head members to help you out precisely if you could please elaborate your project.

2014-07-28 06:05:05 -0500 commented question opencv_createsamples question on file format

Yes,you can use that format too.

2014-07-26 12:18:56 -0500 commented question How to create our own Haarcascade.xml.

That is a truly apt statement Steven. Even a simple google search will pop out all solutions from our forum.

2014-07-26 08:20:49 -0500 commented question How to create our own Haarcascade.xml.
2014-07-24 01:23:44 -0500 answered a question SVM in OpenCV

Hello,

I have written a code that fetches HOG features from a given set of data and trains accordingly. Now remember to change the parameters as per the comments in the code. Also I am mentioning a code that will allow you to test the svm_training. Both the codes have been written and tested in Ubuntu(linux)

#################svmTrain.cpp
#include "cv.h" 
#include "highgui.h"
#include "ml.h"
#include <stdio.h>
#include <iostream>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>
#include <sstream>
#include <string>
#include <cstring>
#include <stdlib.h>

using namespace cv; 
using namespace std;

void reverse(char str[], int length)
{
    int start = 0;
    int end = length -1;
    while (start < end)
    {
        swap(*(str+start), *(str+end));
        start++;
        end--;
    }
}

// Implementation of itoa()
char* itoa(int num, char* str, int base)
{
    int i = 0;
    bool isNegative = false;

    /* Handle 0 explicitely, otherwise empty string is printed for 0 */
    if (num == 0)
    {
        str[i++] = '0';
        str[i] = '\0';
        return str;
    }

    // In standard itoa(), negative numbers are handled only with
    // base 10. Otherwise numbers are considered unsigned.
    if (num < 0 && base == 10)
    {
        isNegative = true;
        num = -num;
    }

    // Process individual digits
    while (num != 0)
    {
        int rem = num % base;
        str[i++] = (rem > 9)? (rem-10) + 'a' : rem + '0';
        num = num/base;
    }

    // If number is negative, append '-'
    if (isNegative)
        str[i++] = '-';

    str[i] = '\0'; // Append string terminator

    // Reverse the string
    reverse(str, i);

    return str;
}

int main()  
{  
 //variables  

 char FirstFileName[100]="train/";                  //the location of the training images.Both positives and negatives must be in same folder
 char lastname[100] = ".JPG";                       //type of the images
 float data[1000][3];                               
 int FileNum=5781;                                  //Number of images(Positives + negatives)

 vector< vector < float> > v_descriptorsValues;  
 vector< vector < Point> > v_locations;  
 Mat Hogfeat; 
 float labelsMat[5781];                              //Length of array must be equal to number of training images

 int img_area = 1*61236;                    //61236 is the number of features detected. Make sure you mention the number of features detected.
 Mat training_mat(FileNum,img_area,CV_32FC1);

//  Mat training_mat(4, 2, CV_32FC1, trainingData);
 for(int i=1; i<=FileNum; i++)  
 {  

  char FullFileName[100] = "";
  char number[100] = "";
  strcat(FullFileName,FirstFileName);
    itoa(i,number,10);
    strcat(FullFileName,number);
    strcat(FullFileName,lastname);

  //read image file  

  Mat img, img_gray;  
  img = imread(FullFileName);  

  //resizing  
  resize(img, img, Size(64,48) ); //Size(64,48) ); //Size(32*2,16*2)); //Size(80,72) );   
  //gray  
  cvtColor(img, img_gray, CV_RGB2GRAY);

    if(i < 1761)                                 // i must be less han number of positives
        {
            labelsMat[i-1] = 1.0;
        }
        else
        {
            labelsMat[i-1] = -1.0;
        }
//      cout << "values of " << d << " filled in training_mat" << endl;  

  //extract feature  
  HOGDescriptor d( Size(32,16), Size(8,8), Size(4,4), Size(4,4), 9);  
  vector< float> descriptorsValues;  
  vector< Point> locations;  
  d.compute( img_gray, descriptorsValues, Size(0,0), Size(0,0), locations);  

  v_descriptorsValues.push_back( descriptorsValues );  
  v_locations.push_back( locations );

    Hogfeat.create(descriptorsValues.size(),1,CV_32FC1);
//  cout << descriptorsValues.size() << endl;
    for(int j=0;j<descriptorsValues.size();j++)
    {
     Hogfeat.at<float>(0,j)=descriptorsValues.at(j);
    }

/*  int ii = 0; // Current column in training_mat
        for (int p = 0; p<Hogfeat.rows; p++) 
        {
            for ...
(more)
2014-07-20 03:52:55 -0500 received badge  Necromancer (source)
2014-07-20 01:26:22 -0500 commented question Question about OpenCV

Please be more specific about your application.

2014-07-20 01:24:10 -0500 answered a question motempl.c lag
2014-07-20 01:21:17 -0500 commented question Calculate Motion
2014-07-16 10:37:50 -0500 commented question Combining C and C++ code together?

And to add to Steven's comment, To convert IplImage to Mat: If test1 is an IplImage, Mat test2(test1); and to convert the Mat image back to IplImage go for this: Mat test2; IplImage test3 = test2; IplImage* test4 = &amp;test3;

The test4 now is your new IplImage back. :)

2014-07-16 10:30:44 -0500 commented question C++ OpenCV 0xC0000005 error when reading from camera

The code worked for me in the ubuntu platform after making some minor changes by 1.putting an # before the include statement 2.replacing DEFINE by just normal declaration of "int". I hope you can try that, otherwise if there is some linking problem with the vs10 have a look at this: http://abhishek4273.wordpress.com/2014/07/10/working-with-opencv-in-windows/

2014-07-14 12:29:26 -0500 commented answer How to determine the distance between the camera and the face in Android?

I have added links. :)

2014-07-14 12:26:08 -0500 edited answer How to determine the distance between the camera and the face in Android?

Hi Nishant,

You will be needing stereo images to find the distance.Calibrate your camera using OpenCV only. Get the intrinsic parameters which include the focal length and all. Create a disparity map using StereoBM or Stereo_SGBM, With the help of that depth map try to find the final distance.

As requested these links might help you:

  1. http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html

  2. http://wiki.ros.org/camera_calibration/Tutorials/StereoCalibration

  3. http://www.jayrambhia.com/blog/stereo-calibration/

  4. http://blog.martinperis.com/2011/01/opencv-stereo-camera-calibration.html

  5. http://abhishek4273.wordpress.com/2014/07/09/playing-with-stereo-images-and-depth-map/

  6. http://abhishek4273.wordpress.com/2014/02/20/camera-calibration-using-opencv/

2014-07-10 01:21:01 -0500 commented answer Visual studio 10 and openCV ?