Ask Your Question

GANESH PRASAATH L's profile - activity

2018-11-01 17:17:52 -0500 received badge  Popular Question (source)
2017-08-22 09:18:35 -0500 received badge  Student (source)
2016-03-19 01:45:24 -0500 commented question Calculating LBP

sorry edited the question

2016-03-19 01:43:34 -0500 commented answer Calculating LBP

thank you berak it worked

2016-03-19 01:15:13 -0500 asked a question Calculating LBP

I tried calculating Local Binary Pattern for an image.

#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"

#include <iostream>
#include <fstream>
#include <sstream>

using namespace cv;
using namespace std;


int main() 
{
    Mat img=imread("G:/Capture.png");
    Mat dst = Mat::zeros(img.rows-2, img.cols-2, CV_8UC1);
    for(int i=1;i<img.rows-1;i++) 
    {
        for(int j=1;j<img.cols-1;j++) 
        {
            uchar center = img.at<uchar>(i,j);
            unsigned char code = 0;
            code |= ((img.at<uchar>(i-1,j-1)) > center) << 7;
            code |= ((img.at<uchar>(i-1,j)) > center) << 6;
            code |= ((img.at<uchar>(i-1,j+1)) > center) << 5;
            code |= ((img.at<uchar>(i,j+1)) > center) << 4;
            code |= ((img.at<uchar>(i+1,j+1)) > center) << 3;
            code |= ((img.at<uchar>(i+1,j)) > center) << 2;
            code |= ((img.at<uchar>(i+1,j-1)) > center) << 1;
            code |= ((img.at<uchar>(i,j-1)) > center) << 0;
            dst.at<uchar>(i-1,j-1) = code;
        }
    }
        imshow("LBP",dst);
        imshow("Source",img);
        waitKey(0);
    return 0;
}

The output images are:image description

The LBP image is not complete.

But What I expect is :

image description

2016-03-17 11:24:14 -0500 asked a question Accessing pixel values in colour image

the following lines show error

Size shist = frame.size();
int histrows = shist.height;
int histcols = shist.width;
for(int igan=0;igan<histrows;igan++)
for(int jgan=0;jgan<histcols;jgan++)
 if(fore.at<uchar>(igan,jgan)!=0)
 forhistogram.at<uchar>(igan,jgan)=frame.at<uchar>(igan,jgan);
 else
 forhistogram.at<uchar>(igan,jgan)=0;
2016-03-09 02:27:01 -0500 commented question accessing elements in vector of vector of points

please reply what is wrong because the last 6 lines show error

2016-03-09 01:01:54 -0500 asked a question accessing elements in vector of vector of points

I tried people counting using HOG descriptor. When the program is compiled, the last part of the program for people counting shows errors.

  HOGDescriptor hog;
    hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
    namedWindow("people detector", 1);
    int required,incoming,outgoing;
  required=0;
  incoming=0;
   outgoing=0;
    for(;;)
    {
        vector<Rect> found, found_filtered;
        double t = (double)getTickCount();
        hog.detectMultiScale(img, found, 0, Size(8,8), Size(32,32), 1.05, 2);
        t = (double)getTickCount() - t;
        printf("tdetection time = %gms\n", t*1000./cv::getTickFrequency());
        size_t i, j;
        for( i = 0; i < found.size(); i++ )
        {
            Rect r = found[i];
            for( j = 0; j < found.size(); j++ )
                if( j != i && (r & found[j]) == r)
                    break;
            if( j == found.size() )
                found_filtered.push_back(r);
        }
Point pt,ptretrieve;

vector<vector<Point>>rectcount;
for(i=0;i<found_filtered.size();i++)
{
Rect r = found_filtered[i];
pt.x=r.tl().x+(r.br().x-r.tl().x)/2;
pt.y=r.tl().y+(r.br().y-r.tl().y)/2;
for(ii=0;ii<found_filtered.size();ii++)
{
ptretrieve=rectcount[ii].back;
if(pt.x-ptretrieve.x<=3&&pt.y-ptretrieve.y<=3)
{
required=ii;
break;
}
}
ptretrieve=rectcount[required].back;
if(pt.x==150&&ptretrieve.x==151)
incoming++;
if(pt.x==150&&ptretrieve.x==149)
ougoing++;
rectcount[required].push_back(pt);
}
2016-03-04 03:20:04 -0500 commented question background subtraction

thanks working on it

2016-03-04 00:05:02 -0500 asked a question background subtraction

i have tried below example to subtract Image's background, its working well and updates position of the object but for the first time i mean when camera starts if i move an object from its initial position to some other position, its initial position Blob is not getting erased. Here's my code:

#include < iostream>
#include < opencv2\opencv.hpp>
#include < opencv2/core/core.hpp>
#include < opencv2/highgui/highgui.hpp>
#include < opencv2/video/background_segm.hpp>

using namespace cv;
using namespace std;

int main()
{
//global variables
Mat frame; //current frame
Mat resizeF;
Mat fgMaskMOG; //fg mask generated by MOG method
Mat fgMaskMOG2; //fg mask fg mask generated by MOG2 method
Mat fgMaskGMG; //fg mask fg mask generated by MOG2 method
Ptr< BackgroundSubtractor> pMOG; //MOG Background subtractor
Ptr< BackgroundSubtractor> pMOG2; //MOG2 Background subtractor
Ptr< BackgroundSubtractorGMG> pGMG; //MOG2 Background subtractor
pMOG = new BackgroundSubtractorMOG();
pMOG2 = new BackgroundSubtractorMOG2();
pGMG = new BackgroundSubtractorGMG();
char fileName[100] = "F:/Project/ShopAssistant2cor.mpg"; 
VideoCapture stream1(fileName);
Mat element = getStructuringElement(MORPH_RECT, Size(3, 3), Point(1,1) );

while (true) {
Mat cameraFrame;
if(!(stream1.read(frame))) 
break;

Mat resizeF=frame;
pMOG->operator()(resizeF, fgMaskMOG);
pMOG2->operator()(resizeF, fgMaskMOG2);
pGMG->operator()(resizeF, fgMaskGMG);

imshow("Origin", resizeF);
imshow("MOG", fgMaskMOG);
imshow("MOG2", fgMaskMOG2);
imshow("GMG", fgMaskGMG);
if (waitKey(30) >= 0)
break;
}
}
2016-03-03 03:54:55 -0500 commented question how to retrieve values from vector

thanks berak

2016-03-02 23:03:18 -0500 asked a question how to retrieve values from vector

Please provide complete instruction set for vector

2016-03-01 21:35:16 -0500 answered a question haarcascade_eye_tree_eyeglasses seems to be broken

Check whether haarcascade_eye_tree_eyeglasses.xml is available correctly. Try to extract opencv package again.

2016-03-01 10:48:11 -0500 commented question How to free memory allocated by UMat?
2016-03-01 10:13:23 -0500 answered a question what is error in this question

I executed this code. No error was shown.It really works.

2016-03-01 02:40:06 -0500 asked a question Need any code for pedestrian counting using trip wire

using C++ , I need to implement pedestrian counting

I read this post : http://answers.opencv.org/question/22...

But I have very little idea of how to implement it.

2016-03-01 02:35:54 -0500 received badge  Enthusiast
2016-02-26 00:02:34 -0500 asked a question How to use X64 and X86???

I installed Visual Studio 2010 and opencv 2.4.9 in windows 7 64 bit. When I use X64 for library, there is a link error showing incompatible with machine. When X86 is used, errors are shown for dll files missing. After providing dll files one by one, finally there is compilation error. How to execute opencv c++ programs?????

2016-02-25 23:54:01 -0500 asked a question How to include ros.h and other ros headers??
#include <ros/ros.h>
#include <ros/package.h>
#include <geometry_msgs/Point.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>

#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <cv.h>

#include <unistd.h> // only for unix?
#include <boost/filesystem.hpp>
#include <vector>

#include <iostream>
#include <string>
#include <sstream>

namespace fs = ::boost::filesystem;
using namespace std;
using namespace cv;

static const std::string OPENCV_WINDOW = "Image window";

#define drawCross( center, color, d )                   \
  line( img, Point( center.x - d, center.y - d ), Point( center.x + d, center.y + d ), color, 2, CV_AA, 0); \
  line( img, Point( center.x + d, center.y - d ), Point( center.x - d, center.y + d ), color, 2, CV_AA, 0 )

#define CLIP_CHAR(c) ((c)>255?255:(c)<0?0:(c))

class DetectorNode
{
  ros::NodeHandle nh_;
  image_transport::ImageTransport it_;
  image_transport::Subscriber image_sub_;
  image_transport::Publisher image_pub_;
  ros::Publisher coord_pub;



  // Kalman-related variables
  bool kalmanHasBeenSetup;
  KalmanFilter KF;
  vector<Point> kalmanv;
  int kalmanCounter;
  Mat_<float> measurement;
  HOGDescriptor hog;

public:

  DetectorNode(ros::NodeHandle n)
    : nh_(n),
      it_(n)
  {
    ROS_DEBUG("Detector node constructor started");
    // Subscrive to input video feed and publish output video feed
    coord_pub = n.advertise<geometry_msgs::Point>("detector_topic", 1);
    image_sub_ = it_.subscribe("image", 1,
                   &DetectorNode::imageCb, this);
    //          descriptor_sub = nh_.subscribe<cdio_messages::descriptor>
    //  ("descriptors", 1, &DetectorNode::descriptorCb, this);

    //cv::namedWindow(OPENCV_WINDOW);
    ROS_DEBUG("Detector Node started");

    hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
    kalmanHasBeenSetup = false;
  }

  ~DetectorNode()
  {
    cv::destroyWindow(OPENCV_WINDOW);
  }

  bool kalmanIsSetup()
  {
    return kalmanHasBeenSetup;
  }

  void setupKalman(float x_coord, float y_coord)
  {
    ROS_DEBUG("Setup Kalman filter");

    KF.init(4,2,0);
    KF.transitionMatrix = *(Mat_<float>(4, 4) << 1,0,1,0,   0,1,0,1,  0,0,1,0,  0,0,0,1);
    measurement.create(2,1); 
    measurement.setTo(Scalar(0));

    KF.statePre.at<float>(0) = x_coord;
    KF.statePre.at<float>(1) = y_coord;
    KF.statePre.at<float>(2) = 0;
    KF.statePre.at<float>(3) = 0;
    setIdentity(KF.measurementMatrix);
    setIdentity(KF.processNoiseCov, Scalar::all(1e-2)); // Bigger number => faster update
    setIdentity(KF.measurementNoiseCov, Scalar::all(10));
    setIdentity(KF.errorCovPost, Scalar::all(.1));

    // Reset the kalman result vector and counter
    kalmanv.clear();
    kalmanCounter = 0;
    kalmanHasBeenSetup = true;
  }

  void imageCb(const sensor_msgs::ImageConstPtr& msg)
  {
    // Convert image message to OpenCV format
    cv_bridge::CvImagePtr cv_ptr;

    try
      {
    cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);
      }
    catch (cv_bridge::Exception& e)
      {
    ROS_ERROR("cv_bridge exception: %s", e.what());
    return;
      }


    //bool found_object = false;
    Point object_coordinates;
    Mat imgBig, img;

    namedWindow("HOG - Detect people", CV_WINDOW_AUTOSIZE);
    img = cv_ptr->image;


    // Get image sizes
    float imgWidth = (img.size()).width;
    float imgHeight = (img.size()).height;

    bool usingKalman = true;
    int kalmanCounterMax = 5;

    if(kalmanIsSetup() && usingKalman)
    {
      ROS_DEBUG("Predict and update Kalman filter");
      // Predict and update Kalman filter
      Mat prediction = KF.predict();
      Point predictPt(prediction.at<float>(0),prediction.at<float>(1));
      Mat estimated = KF.correct(measurement);
      Point statePt(estimated.at<float>(0),estimated.at<float>(1));
    }

    vector<Rect> found, found_filtered;
    hog.detectMultiScale(img, found, 0, Size(8,8), Size(32,32), 1.05, 2);


    size_t i, j;
    size_t biggest = 0;
    Rect biggestRect;
    for (i=0; i<found.size(); i++)
      {
    Rect r = found[i];
    for (j=0; j<found.size(); j++)
      if (j ...
(more)
2016-02-25 23:51:28 -0500 commented answer Where to find string.h??

it does not work

2016-02-25 03:12:19 -0500 commented answer Where to find string.h??

did the same but that does not work

2016-02-25 03:11:43 -0500 received badge  Critic (source)
2016-02-24 03:39:35 -0500 asked a question Where to find string.h??

fatal error C1083: Cannot open include file: 'string/string.h': No such file or directory

2016-02-24 03:04:58 -0500 answered a question How to change BGR to RGB of a video frame using C /C++
2016-02-24 03:01:06 -0500 answered a question Linking OpenCV 2.4.2 with Visual Studio 2012
2016-02-24 03:00:17 -0500 received badge  Supporter (source)
2016-02-24 02:56:29 -0500 commented question opencv slow on ubuntu

Speed doesnot depend on OS, it depends only on processor

2016-02-17 02:26:45 -0500 commented question compilation error

exactly code was compiled but dont know why there is exception error

2016-02-17 02:24:20 -0500 commented question cascade classifier doesnot work for image input

now replaced variable name 'new' with 'frame' sorry to post the wrong code

2016-02-17 02:22:51 -0500 received badge  Editor (source)
2016-02-16 22:12:25 -0500 asked a question error in cascade classifier for image input

i have implemented using MS visual studio 2010 and opencv 2.4.9


    #include "opencv2/objdetect/objdetect.hpp"
 #include "opencv2/highgui/highgui.hpp"
 #include "opencv2/imgproc/imgproc.hpp"

 #include "iostream"
 #include "stdio.h"

using namespace std;
using namespace cv;

int main()
{
    Mat frame=imread("F:\\new.jpg");
    namedWindow("HAAR");
    CascadeClassifier face_cascade; 
    vector<Rect> faces;
    Mat frame_gray;

    cvtColor( frame, frame_gray, CV_BGR2GRAY );
    equalizeHist( frame_gray, frame_gray );
    if( !face_cascade.load( "haarcascade_frontalface_alt.xml") )
    { 
      printf("--(!)Error loading\n");
      return -1;
    };
    face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
    for( size_t i = 0; i < faces.size(); i++ )
    {
         Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
         ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
    }
    imshow("HAAR", frame );
}


----------
2016-02-16 22:04:39 -0500 asked a question compilation error

I could not compile my code and I get the following exception error always. Unhandled exception at 0x74c7b760 (KernelBase.dll) in firstexample.exe: Microsoft C++ exception: cv::Exception at memory location 0x0013afe4.. at some times errors are shown

2016-02-16 02:23:49 -0500 asked a question cascade classifier doesnot work for image input

given below is my code

#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;

int main()
{
    Mat new=imread("F:\new.jpg");
    namedWindow("HAAR");
    CascadeClassifier face_cascade; 
    vector<Rect> faces;
    Mat frame_gray;

    cvtColor( new, frame_gray, CV_BGR2GRAY );
    equalizeHist( frame_gray, frame_gray );
    if( !face_cascade.load( "haarcascade_frontalface_alt.xml") )
    { 
      printf("--(!)Error loading\n");
      return -1;
    };
    face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
    for( size_t i = 0; i < faces.size(); i++ )
    {
         Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
         ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 4, 8, 0 );
    }
    imshow("HAAR", frame );
}

MS visual studio 2010 and opencv 2.4.9 are used. no error is displayed build is successful

2015-09-21 01:58:38 -0500 answered a question opencv slow on ubuntu

Speed depends on clock speed

2015-09-21 01:49:34 -0500 asked a question Visual Studio 2010

How to solve the error 'could not locate Cl.exe'