Ask Your Question

GiulSDU's profile - activity

2018-10-04 07:49:27 -0500 received badge  Popular Question (source)
2018-06-04 12:49:10 -0500 received badge  Notable Question (source)
2018-03-20 07:01:56 -0500 received badge  Famous Question (source)
2017-09-19 13:32:18 -0500 received badge  Famous Question (source)
2017-01-10 03:48:53 -0500 received badge  Popular Question (source)
2016-05-20 22:47:52 -0500 received badge  Student (source)
2016-01-24 23:06:30 -0500 received badge  Notable Question (source)
2015-10-22 08:42:47 -0500 received badge  Notable Question (source)
2015-07-07 13:04:17 -0500 received badge  Popular Question (source)
2015-03-09 22:02:36 -0500 received badge  Popular Question (source)
2014-05-18 09:26:39 -0500 received badge  Supporter (source)
2014-05-18 08:37:35 -0500 commented answer 3d point reconstruction

that works fine thanks!! i tried to crop the original images a little bit and to use the same matching algorithm as before..the problem is that i get very different 3d-points coordinates...but the object is just the same....and i did not change the position..i just cropped the image..aren t i suppose to get the same 3d point regardless to the xy coordinate of the object in the image? can you see the error somewhere? thank you

2014-05-17 06:58:36 -0500 asked a question 3d point reconstruction

Hi, i have two 2d points from two rectified images, they match. How can i now compute the 3d point? I have both projection matrix. thank you

2014-04-13 16:17:51 -0500 asked a question Using multiple external cameras

Hi, i am using 2 external webcams. The problem is that openCV does not recognize the second one, and it is the same exact model of the first one..here is my code

int main(int, char**)
{
VideoCapture cap(0); // open the default camera
VideoCapture web(1);
VideoCapture web2(2);

Mat laptop;
cap >> laptop;
imshow("laptop ", laptop);


Mat webcam;
web >> webcam;
imshow("webcam", webcam);

Mat webcam2;
web2 >> webcam2;
imshow("webcam2", webcam2);
waitKey();
return 0;
}

It is an easy program to understand the index of my cameras. The problem is that i got the built-in camera to the index 0, one external webcam to index 1 ..and does not link the third camera to any index. Here is the output

HIGHGUI ERROR: V4L: index 2 is not correct!
libv4l2: error turning on stream: No space left on device
VIDIOC_STREAMON: No space left on device
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /build/buildd/opencv-2.3.1/modules/core/src/array.cpp, line 2482
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/buildd/opencv-2.3.1/modules/core/src/array.cpp:2482: error: (-206) Unrecognized or unsupported array type in function cvGetMat

thank you

2014-02-24 04:23:18 -0500 commented question Acquiring video from webcam problems.

i actually found out that if i try to test video for Linux 2 (v4l2) in Multimedia system selector.. it fails..the problme maybe is here somewhere

2014-02-24 04:21:57 -0500 commented question Acquiring video from webcam problems.

no well is just a code i downloaded from the web to test the camera..

2014-02-24 04:07:21 -0500 asked a question Acquiring video from webcam problems.

Hi , i am trying to acquire a video from my webcam, this is the code i am using

> #include <opencv2/objdetect/objdetect.hpp>
> #include <opencv2/highgui/highgui.hpp>
> #include <opencv2/imgproc/imgproc.hpp>
> #include <opencv2/core/core.hpp>
> #include <stdlib.h>
> #include <stdio.h>
> #include <iostream>
> #include <stdio.h>
> #include <iostream>
> 
> 
> using namespace std; using namespace
> cv;
> 
> char key;
> 
> 
> 
> 
> using namespace std;
> 
> int main() {
>       //Create window      namedWindow("Camera_output", 1);
>   CvCapture* capture =
> cvCaptureFromCAM(1);  //Capture using
> any camera connected to your system
> 
>   while(1){ //Create infinte loop for
> live streaming
> 
>         IplImage* frame = cvQueryFrame(capture); //Create image
> frames from capture
>         Mat frame2=frame;
>         cvtColor( frame2, frame2, CV_BGR2GRAY );
>         imshow("pepper_noise padded", frame2);
> 
>         key = cvWaitKey(10);     //Capture Keyboard stroke
>         if (char(key) == 27){
>             break;      //If you hit ESC key loop will break.
>         }
> 
>     }
>     cvReleaseCapture(&capture); //Release capture.
>     cvDestroyWindow("Camera_Output"); //Destroy Window
>     return 0; }

after the first iteration the camera works fine but i get this output:

> VIDIOC_QUERYMENU: Invalid argument
> VIDIOC_QUERYMENU: Invalid argument
> VIDIOC_QUERYMENU: Invalid argument

if then i try to compile it again it does not work and i get this error:

libv4l2: error turning on stream: Invalid argument
VIDIOC_STREAMON: Invalid argument

any idea? i also tried to use an usb cam but does not work either.. I am using a laptop with Nvidia optimus but u actually deleted the Nvidia Drivers, so i am using the intel graphic card, can this be a problem?

2013-11-10 04:21:01 -0500 asked a question OpenCv error and Usb ports disabled

Hi, i am trying to perform image acquiring from webcam The code is the following

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


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

using namespace std;
using namespace cv;

#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char* argv[])
{
    VideoCapture cap(0); // open the video camera no. 0

    if (!cap.isOpened())  // if not success, exit program
    {
        cout << "Cannot open the video file" << endl;
        return -1;
    }

   double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
   double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video

    cout << "Frame size : " << dWidth << " x " << dHeight << endl;

    namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

    while (1)
    {
        Mat frame;

        bool bSuccess = cap.read(frame); // read a new frame from video

         if (!bSuccess) //if not success, break loop
        {
             cout << "Cannot read a frame from video file" << endl;
             break;
        }

        imshow("MyVideo", frame); //show the frame in "MyVideo" window

        if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
       {
            cout << "esc key is pressed by user" << endl;
            break;
       }
    }
    return 0;

}

the first time runs but i get the following error:

VIDIOC_QUERYMENU: Invalid argument

and after running the program all the usb ports are disabled, i have to restart the laptop to get hem enabled again.

The second time i try to run the code the camera cannot be found, and it sounds reasonabe since all the ports seem to be disabled. Thank you

2013-10-17 07:36:42 -0500 commented question Sharpening image

as a scale i m applying -1.0 ..

2013-10-17 07:22:14 -0500 commented question Sharpening image

Question edited

2013-10-17 07:16:40 -0500 received badge  Editor (source)
2013-10-17 06:55:46 -0500 asked a question Sharpening image

Hi, i want to sharp an image and i am using the laplacian operator. I have the blurred image, compute the laplacian (the grayish image where is easy to see the boarder ) but when i add them i have a weird output. The image get worst. The same by subtraction..d you know why? Thank you

this is how i compute the lalpacian..

#include "LaplacianZC.h"

LaplacianZC::LaplacianZC() : aperture(3) {}

void LaplacianZC::setAperture(int a)
{
aperture=a;
}


Mat LaplacianZC::computeLaplacian(const Mat& image)
{
Laplacian(image,laplace,CV_32F);

img=image.clone();

return laplace;
}

Mat LaplacianZC::getLaplacianImage(double scale)
{
if (scale <0)
    {
    double lapmin,lapmax;
    minMaxLoc(laplace,&lapmin,&lapmax);
    scale=127/max(-lapmin,lapmax);
    }

Mat laplaceImage;
laplace.convertTo(laplaceImage,CV_8U,scale,128);




return laplaceImage;
}

here is my image C:\fakepath\blurred.png

and the laplacian C:\fakepath\laplacian.png

I just add them as follows:

addWeighted(blurred,1,laplacian,1,0,output,-1);

thanks

2013-10-15 09:15:46 -0500 commented question Max function and datatype

because..the value of my image go from 0 to 255...so i thought an integer would be enough..

2013-10-15 08:56:32 -0500 asked a question Max function and datatype

I am tryong to compute the max of a certain image, my function is:

int maxFilter(Mat img,int x,int y)
{
int max=0;
for (int j = x-1; j <= x+ 1; j++)
{
    uchar* data = img.ptr<uchar>(j);
    for(int i =y-1 ; i <= y+1; i++)
    {
        if (data[i]>=max)
            max=data[i];

    }
}

return max;
}

the problem is that i use the following code to access pixel: Mat padded; //loading the picture here//

for(int j = 1; j < padded.rows-1; j++)
{
    uchar* data = padded.ptr<uchar>(j);
    for(int i = 1; i < padded.cols-1; i++)
    {

    data[i]=maxFilter(padded,j,i);

    }
}

the Image is a Mat with an uchar pointer, but the return value of my function is an integer, how can i fix it? do you know any type assignment tutorial?

2013-10-11 09:27:07 -0500 commented question laplace-image sharpening

would be great but laplacian function seems difficult as well

2013-10-11 09:04:41 -0500 commented question laplace-image sharpening

but it doesn't.i just get a picture with random white and black pixel

2013-10-11 06:17:42 -0500 asked a question laplace-image sharpening

Hi, i need to sharp an image. Trying to use Lapacian filter but get the same figure as output. Can t find the error in the code

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>

using namespace cv;
using namespace std;
float laplacian(Mat image,int x,int y)
{

    float sum=0;
    float value=0;
    for(int j = x-1; j <= x+ 1; j++)
    {
        uchar* data = image.ptr<uchar>(j);
        for(int i = y-1; i <= y+1; i++)
        {
            if (j==x && i==y)
            {
                value=data[i]*(-8);
            }

            else value=data[i];

         sum=sum+value;

        }
    }

return sum;
}
Mat paddImage(Mat image,int size,int borderType)
{
Mat padded;
int top, bottom, left, right;
Scalar value;


top = size; bottom = size;
left = size; right = size;


copyMakeBorder( image, padded, top, bottom, left, right, borderType);

return padded;
}


int main( int argc, char** argv )
{


    if( argc != 2)
    {
        cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
        return -1;
    }

    Mat blurred;

    blurred=imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE );

    namedWindow("blurred", CV_WINDOW_AUTOSIZE );
    imshow("blurred", blurred );

      Mat padded=paddImage(blurred,1,BORDER_CONSTANT);
        namedWindow("blurred pad", CV_WINDOW_AUTOSIZE );
        imshow("blurred pad", padded );



            for(int j = 1; j < padded.rows-1; j++)
                        {
                            uchar* data = padded.ptr<uchar>(j);
                            for(int i = 1; i < padded.cols-1; i++)
                            {

                                data[i]=data[i]-((-1/9)*laplacian(padded,j,i))*data[i];

                            }
                        }


            namedWindow("sharpen", CV_WINDOW_AUTOSIZE );
            imshow("sharpen", padded );

    waitKey(0);
    return 0;
}
2013-10-03 02:30:47 -0500 asked a question Mean and variance from Hisotgram

Hi, i have a picture and after computing the Histogram i need to compute mean and variance. There is a easy way to do it? Tanks

2013-09-29 10:16:11 -0500 commented question weird Histogram error

The error was in the imread..wrong flag

2013-09-29 10:00:43 -0500 asked a question weird Histogram error

Hi, i get a weird error trying to compute the histogram of a gray picture. This is the error i get:

OpenCV Error: Assertion failed (images[j].channels() == 1) in histPrepareImages, file /build/buildd/opencv-2.3.1/modules/imgproc/src/histogram.cpp, line 139 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.3.1/modules/imgproc/src/histogram.cpp:139: error: (-215) images[j].channels() == 1 in function histPrepareImages

and this is my code:

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


using namespace cv;
using namespace std;




int main( int argc, char** argv )
{
    if( argc != 2)
    {
        cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
        return -1;
    }

    Mat pepper_noise;
    pepper_noise = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

    if(! pepper_noise.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow("pepper_noise", CV_WINDOW_AUTOSIZE );
    imshow("pepper_noise", pepper_noise );

    /// Establish the number of bins
      int histSize = 256;

      /// Set the ranges ( for B,G,R) )
      float range[] = { 0, 256 } ;
      const float* histRange = { range };

      bool uniform = true; bool accumulate = false;

      Mat b_hist;

      /// Compute the histograms:

      calcHist( &pepper_noise, 1, 0, Mat(), b_hist, 1, &histSize, &histRange, uniform, accumulate );

      // Draw the histograms 
      int hist_w = 512; int hist_h = 400;
      int bin_w = cvRound( (double) hist_w/histSize );

      Mat histImage( hist_h, hist_w, CV_8UC1, 0 );

      /// Normalize the result to [ 0, histImage.rows ]
      normalize(b_hist, b_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );

      /// Draw for each channel
      for( int i = 1; i < histSize; i++ )
      {
          line( histImage, Point( bin_w*(i-1), hist_h - cvRound(b_hist.at<float>(i-1)) ) ,
                           Point( bin_w*(i), hist_h - cvRound(b_hist.at<float>(i)) ),
                                 255, 2, 8, 0  );
      }

      /// Display
      namedWindow("calcHist Demo", CV_WINDOW_AUTOSIZE );
      imshow("calcHist Demo", histImage );



    waitKey(0);
return 0;
}
2013-09-27 07:55:00 -0500 asked a question Get multiple image after inverse Fourier trasform

Hi, after applying a filter to the image+s fourier trasform i then compute the inverse. I get the image but 3 times in the same window. Where is the error????

restore_spectrum is the image i want to aply the inverse traform to.

dftshift(restored_spectrum);

        Mat_<float> imagesx_y[2];

        polarToCart(restored_spectrum, moon_phase,imagesx_y[0], imagesx_y[1], false);
        Mat_<Vec2f> im;
        Mat_<float> moonRestored;

        merge(imagesx_y,2,im);

        dft(im, moonRestored, DFT_INVERSE + DFT_SCALE + DFT_REAL_OUTPUT);

        normalize(moonRestored, moonRestored, 0, 1, CV_MINMAX);

        namedWindow("RestoredImage ", CV_WINDOW_AUTOSIZE );
        imshow("RestoredImage ", moonRestored);
2013-09-25 15:17:14 -0500 asked a question Can't compute power of float point

Hi, i have a Mat<float> image. After making the fourier spectrum of the image i have to apply a Butterworth filter of equation: H(u,v)=1/(1+[D(u,v)/250]⁴) where

D(u,v)=[(u-(image.col/2)²)+(v-(image.row/2)²))]^0.5

as you can see there are many power function in the image. My image is a Mat_<float>, so i suppose that the result of each computation should be a float, so i can change each pixel of the image with the result of the equation. Unfortuntely my code seems not to work , i have problems with the function pow..seems to work only for certain type.. here is my code

Mat_<float> filter;
    moon_spectrum.copyTo(filter);//giving the same dimentions

    for (int i=0;i<filter.cols;i++)
    {
        for (int j=0;j<filter.rows;j++)
        {
            float d_x=pow((i-filter.cols),2);
            float d_y=pow((j-filter.rows),2);
            float d=pow((d_x+d_y),2);
            float d_fin=pow((d/250),4);
            filter.at<float>(i,j)=1/(1+d_fin);



        }
2013-09-24 13:37:48 -0500 received badge  Organizer (source)
2013-09-24 11:57:03 -0500 asked a question Inverse Fourier gives black figure

Hi, i try to apply the inverse of fourier Trasform to a Image Sperctrum but it does not work, i end up with a black image.

Mat Lena;
   images[0].copyTo(Lena);

   Mat padded;                            //expand input image to optimal size
      int m = getOptimalDFTSize( Lena.rows );
      int n = getOptimalDFTSize( Lena.cols ); // on the border add zero values
      copyMakeBorder(Lena, padded, 0, m - Lena.rows, 0, n - Lena.cols, BORDER_CONSTANT, Scalar::all(0));

      Mat planes[] = {Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F)};
      Mat complexI;
      merge(planes, 2, complexI);         // Add to the expanded another plane with zeros

      dft(complexI, complexI);            // this way the result may fit in the source matrix
      Mat_<float> magI;

      split(complexI, planes);                   // planes[0] = Re(DFT(I), planes[1] = Im(DFT(I))
      magnitude(planes[0], planes[1], planes[0]);// planes[0] = magnitude
      magI=planes[0];

      //shifting

      dftshift(magI);

      magI(cv::Rect(magI.cols/2 - 25, magI.rows/2 -25, 50, 50)) = 250.0f;

       dftshift(magI);


      Mat_<float> filtered;
      //from polar to car
      //phase(planes[1], planes[0], planes[1], false);
      polarToCart(magI,planes[1],planes[0],planes[1],false);
      //merge

      Mat_<Vec2f> complexI_2;
      merge(planes, 2, complexI_2);
      dft(complexI_2, filtered,  DFT_INVERSE + DFT_SCALE + DFT_REAL_OUTPUT, 0);
      normalize(filtered, filtered, 0, 1, CV_MINMAX);

      namedWindow("Filtered Im", CV_WINDOW_AUTOSIZE );
      imshow("Filtered Im", filtered );

      namedWindow("ImageHisto", CV_WINDOW_AUTOSIZE );
      imshow("ImageHisto", histo(Lena) );

      namedWindow("FilteredImage Histo", CV_WINDOW_AUTOSIZE );
      imshow("FilteredImage Histo", histo(filtered) );


    }

Everything is working until i modify the magnitude. I get the modified spectrum (magI) end then i am suppose to compute the inverse Trasform. I think the problem could be in PolarToCar because it takes as parameter the magnitude and the phase, but i am not sure i actually have the phase, i think i have the imaginary part of the spectrum stored in planes[1]. thanks

2013-09-22 10:37:57 -0500 asked a question Loading images in Argument

Hi, i have to load 4 images that i uploaded in the Argument section(run-run properties- arguments) and i am trying to load them with "argv[i]". I always have the same input: Usage: display_image ImageToLoadAndDisplay

Can you please tell me where is the error? i think it may be in the Arguments field, maybe there is some special character to divide arguments, by now i am just writing the location of the image with one space within every location. This is my code.

int main( int argc, char** argv )
{
    if( argc != 2)
    {
        cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
        return -1;
    }

    Mat  images[4];
    Mat spectrum[4];
    for (int i=1;i<5;i++)
    {
        images[i-1]=imread(argv[i], CV_LOAD_IMAGE_GRAYSCALE );

        if(! images[i-1].data )                              // Check for invalid input
            {
                cout <<  "Could not open or find the image" << std::endl ;
                return -1;
            }

    Fourier(images[i-1],spectrum[i-1]);

    string name="image number "+ i;
    string nameSpectrum= "spectrum number " + i;
    namedWindow(name, CV_WINDOW_AUTOSIZE );
    imshow(name, images[i] );

    namedWindow(nameSpectrum, CV_WINDOW_AUTOSIZE );
    imshow(nameSpectrum, spectrum[i] );
    waitKey(0);

    }
2013-09-20 05:56:54 -0500 commented answer Histogram outputs always same picture

Ok now is clear!! That helped a lot!! thank you very much :)

2013-09-20 05:54:54 -0500 marked best answer Histogram outputs always same picture

Hi, i have to compute a histogram for two picture. I then made a function to compute histograms of gray images. The problem is that at the end i always get the same histogram result,regardless to the image. This is my code

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
using namespace cv;
using namespace std;

Mat histo(Mat &src)
{
/// Establish the number of bins
int histSize = 256;

/// Set the ranges ( for B,G,R) )
float range[] = { 0, 256 } ;
const float* histRange = { range };

bool uniform = true; bool accumulate = false;

Mat b_hist;

/// Compute the histograms:
calcHist( &src, 1, 0, Mat(), b_hist, 1, &histSize, &histRange, uniform, accumulate );

// Draw the histograms for B, G and R
int hist_w = 512; int hist_h = 400;
int bin_w = cvRound( (double) hist_w/histSize );

Mat histImage( hist_h, hist_w, CV_8UC3, Scalar(0,0,0) );

/// Normalize the result to [ 0, histImage.rows ]
normalize(b_hist, b_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );

/// Draw for each channel
for( int i = 1; i < histSize; i++ )
{
    line( histImage, Point( bin_w*(i-1), hist_h - cvRound(b_hist.at<float>(i-1)) ) ,
                     Point( bin_w*(i), hist_h - cvRound(b_hist.at<float>(i)) ),
                     255, 2, 8, 0  );

}


return histImage;
}

int main( int argc, char** argv )
{
    if( argc != 2)
    {
    cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
    return -1;
    }

    Mat image,grayImage;
    image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

    if(! image.data )                              // Check for invalid input
    {
        cout <<  "Could not open or find the image" << std::endl ;
        return -1;
    }

    namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Display window", image );                   // Show our image inside it.


    cvtColor( image, grayImage, CV_BGR2GRAY );

    namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Gray image", grayImage );                   // Show our image inside it.

   Mat saturedImage=grayImage;

    for( int y = 0; y < image.rows; y++ )
    {
        for( int x = 0; x < image.cols; x++ )
        {
            saturedImage.at<uchar>(y,x) = saturate_cast<uchar>(saturedImage.at<uchar>(y,x)+50) ;
        }
    }


    namedWindow( "Image3", CV_WINDOW_AUTOSIZE );// Create a window for display.
    imshow( "Image3", saturedImage );                   // Show our image inside it.

// Gray picture Histogram
    namedWindow("calcHist Grey image", CV_WINDOW_AUTOSIZE );
    imshow("calcHist Grey image", histo(grayImage) );

 //Satured image histo
    namedWindow("calcHist Satured image", CV_WINDOW_AUTOSIZE );
    imshow("calcHist Satured image", histo(saturedImage) );


    waitKey(0);

    return 0;
}