Ask Your Question

Saghir Khatri's profile - activity

2019-12-10 04:42:03 -0600 received badge  Notable Question (source)
2019-06-03 08:16:37 -0600 received badge  Popular Question (source)
2017-03-19 15:37:11 -0600 received badge  Student (source)
2016-12-30 00:56:53 -0600 commented answer Opencv select timeout at high resolutions

I got select timeout after running your code.. So its not related to ViceoCapture::set method. Any other thing i can look into??

2016-12-29 01:50:36 -0600 asked a question Opencv select timeout at high resolutions

Hi all. I have an A4Tech pk-336e webcam attached with my BeagleBone and i am using OpenCV to capture images from BeagleBone Black. Issue is when i capture image at 320x240 resolution i get a perfect image but at 640x480 i get select timeout. Although it is written on camera that it supports 640x480 when i type the following command

v4l2-ctl --all

My code to capture image is as follows:

#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( )
{
    cout <<"Start main"<<endl;
    VideoCapture cap(0); // open the default camera
    cap.set(CV_CAP_PROP_FRAME_WIDTH , 640);
    cap.set(CV_CAP_PROP_FRAME_HEIGHT ,480);

    Mat meter_image;
    cap >> meter_image;
    imwrite("/card/imgs.jpg", meter_image);
    return 0;
}

I know its really common issue but i am not sure where i can find the solution as i am able to make it working with Logitech one. Kindly let me know of any thing which helps in solving this... Regards

2016-11-30 05:48:53 -0600 asked a question FitEllipse return bigger ellipse than original ContourSize

I am stuck in weird situation. My fitEllipse method returns a big Ellipse than my original Contour. Here is the output of Image:

enter image description here

and my binary image from which it is generating contour is:

enter image description here

There is no noise or anything but I am still getting a large ellipse.

My code is as follows:

findContours( meter_bin, contours, hierarchy, RETR_LIST, CHAIN_APPROX_SIMPLE);
for (int z=0;z<contours.size();z++)
{
    /* Ignore areas with less area */
    if (contourArea(contours[z])>200)
    {
        Mat pointsf;
        Mat(contours[z]).convertTo(pointsf, CV_32F);
        RotatedRect box = fitEllipse(pointsf);
        if( MAX(box.size.width, box.size.height) > MIN(box.size.width, box.size.height)*30 )
            continue;
        drawContours(img4, contours, (int)z, Scalar::all(255), 1, 8);
        ellipse(img4, box, Scalar(0,0,255), 1, LINE_AA);
        ellipse(img4, box.center, box.size*0.5f, box.angle, 0, 360, Scalar(0,255,255), 1, LINE_AA);
        Point2f vtx[4];
        double length[4];
        box.points(vtx);
        for( int j = 0; j < 4; j++ )
        {
            length[j]=sqrt((vtx[j].x - vtx[(j+1)%4].x) *  (vtx[j].x - vtx[(j+1)%4].x) + (vtx[j].y - vtx[(j+1)%4].y) *  (vtx[j].y - vtx[(j+1)%4].y));
            line(img4, vtx[j], vtx[(j+1)%4], Scalar(0,255,0), 1, LINE_AA);
        }
    }
}

I am not sure why this is happening as everything seems to be fine here. Please let me know what is going wrong here Regards,

2016-11-17 02:13:54 -0600 received badge  Enthusiast
2016-11-14 01:52:35 -0600 received badge  Editor (source)
2016-11-14 01:52:01 -0600 asked a question VideoCapture result in distorted lines in image

I am trying to click an image from Webcam using OpenCV. My code is as follows.

VideoCapture cap0(0);
cap0.set(CV_CAP_PROP_FRAME_WIDTH,320);
cap0.set(CV_CAP_PROP_FRAME_HEIGHT,240);
cap0 >> frame;
string fileName = "/0.jpg";
cout << fileName << endl;
imwrite(fileName, frame);

I am getting this image as output

image description

You can see some weird lines in output., What is the possible reason and how i can eliminate these Please point me to the right direction.

Thanks

2016-11-08 05:26:21 -0600 asked a question Green output image from second Camera

Hi All. I have setup OpenCV 3.1.0 on my BeagleBone Black Rev C. All basic operations are working well. I have attached 3 cameras using USB hub to BBB. I have a simple OpenCV program that iterates through all the available programs and generate images in 3 different folders in OpenCV. I have verified that all cameras are available using lsusb command. Output in first image is fine with just weird lines on image. Output in second image is Green(Weird!). No Image is generated from third camera and i get the following output:

Not Working select timeout

Here is my code:

    int numberOfCameras = 3;
    for(int i=0; i<numberOfCameras; i++){
        cout << i<<endl;
        VideoCapture cap(i);
        if (cap.isOpened())
        {
            cout << "Camera working"<<endl;
        }
        else
        {
            cout<< "Not Working"<<endl;
        }
        cap.set(CV_CAP_PROP_FRAME_WIDTH,320);
        cap.set(CV_CAP_PROP_FRAME_HEIGHT,240);
        Mat frame;

       stringstream ss;
       ss << i;
       if(i==0)
       { 
            string fileName = "/electric1/" + ss.str() + ".jpg";
            Mat frame0;
            cap >> frame0;
            cout << fileName << endl;
            imwrite(fileName, frame0);
      }
      else if(i==1)
      {
            string fileName = "/gas1/" + ss.str() + ".jpg";
            Mat frame1;
            cap >> frame1;
            cout << fileName << endl;
            imwrite(fileName, frame1);
      }
      else if(i==2)
      {
             string fileName = "/water1/" + ss.str() + ".jpg";
             Mat frame2;
             cap >> frame2;
             cout << fileName << endl;
             imwrite(fileName, frame2);
      }
   }

Please let me know why i am getting this issue. Or any hint to right direction will be really great. Thanks

2016-02-08 06:27:08 -0600 asked a question basic OpenCV operations not working in beaglebone black

Hi all!

I am new to OpenCV and BeagleBone Black. I have installed all libraries in beagle bone black but when i try to run following code:

 // Test to convert a color image to gray
 // Build on Linux with:
 // g++ test_2.cpp -o test_2 -lopencv_core -lopencv_imgproc -lopencv_highgui

 #include <opencv2/opencv.hpp>
 #include <iostream>

 using namespace cv;
 using namescpace std;
 int main() {
     // Load the image file and check for success
     Mat input = imread("lena.jpg", 1);
     if(!input.data) {
         cout << "Unable to open the image file" << endl;
         return -1;
     }

     // Convert the input file to gray
     Mat gray_image;
     cvtColor(input, gray_image, COLOR_BGR2GRAY);

     // Save the result
     imwrite("lena_gray.jpg", gray_image);

    return 0;
 }

i get following error at cvtColor line:

CMEM Error: init: Failed to open /dev/cmem: 'No such file or directory'

The cmemk kernel module does not appear to be installed.

Commands such as the following run as root would install cmemk and allow OpenCL to proceed properly.

For available CMEM DDR block size: ~512MB:
modprobe cmemk phys_start=0xa0000000 phys_end=0xc0000000 pools=1x536870912 allowOverlap=1

as mentioned above when i run: modprobe cmemk phys_start=0xa0000000 phys_end=0xc0000000 pools=1x536870912 allowOverlap=1

i get this error on same line:

Ipc_start: LAD_connect() failed: 4
test_2: /build/ti-opencl-zdvBAC/ti-opencl-01.01.06.00/host/src/core/dsp/mbox_impl_msgq.cpp:59: MBoxMsgQ::MBoxMsgQ(Coal::DSPDevice*): Assertion `status == (0) || status == (1)' failed.
Aborted

i tried other methods like findContours, threshold etc but it yields same error.

I dont know why get this problem. please let me know about its workaround

Thanks.