Ask Your Question

Akki's profile - activity

2018-07-01 00:39:19 -0600 received badge  Famous Question (source)
2018-06-12 03:40:21 -0600 received badge  Famous Question (source)
2017-02-27 22:46:14 -0600 received badge  Notable Question (source)
2017-02-22 17:25:42 -0600 received badge  Notable Question (source)
2016-09-27 14:58:03 -0600 received badge  Popular Question (source)
2016-05-26 14:08:00 -0600 received badge  Popular Question (source)
2016-04-16 03:05:39 -0600 commented answer How to detect different random colors from the picture?

Thank you very much.. I will make clear my basics first. Thank you once again.

2016-04-15 16:57:41 -0600 commented answer How to detect different random colors from the picture?

Thank you very much for your suggestion. when I tried to run program, I am Getting error like 'CountColors': identifier not found 'numOfColors' : redefinition; multiple initialization

please help me how can I solve this problem.

Thank you very much once again.

2016-04-15 12:33:04 -0600 commented answer How to detect different random colors from the picture?

Thank you very much for suggestions. I am not so good in programming. I went through the link which you mentioned, but still I didnt understand where I am doing wrong. Sorry for such silly question.

2016-04-15 07:02:12 -0600 commented answer How to detect different random colors from the picture?

Hello, When I am trying to run the program I am getting error: fatal error LNK1561: entry point must be defined. Can you please guide me how can I overcome this. Thank you very much once again.

2016-04-14 10:17:50 -0600 commented answer How to detect different random colors from the picture?

Thank you very much for your help. could you please explain, where to enter the image path.

Thank you very much once again.

2016-04-13 16:24:18 -0600 commented question How to detect different random colors from the picture?

Thank you very much for reply. I have different 4 colors to detect not more than that. and Image is also not so big. its like random color made draw in paint some time its two color some time 3 that is it. I have idea about histogram but I dont know how to implement it. I will also take a look in other suggestions. Thank you very much once again and it will be great help is someone can provide sample program.

2016-04-13 08:23:09 -0600 asked a question How to detect different random colors from the picture?

Hello,

I am doing phase detection program. I would like to know if there is any possibility to say that this picture frame has 3 various color or this picture frame has one color. colors should be changed picture by picture. So I am looking for some logic to say how many different color are there in the picture.

Please guide me. Thank you very much in advance.

2015-12-04 12:47:17 -0600 commented question how to crop ROI?

Thank you very much for your kindly explanation. I will do the same and invest some of my time for it. After that if i have any doubt then I will again post or request here. thanks once again.

2015-12-04 10:18:06 -0600 asked a question how to crop ROI?

Hello, I have already set ROI for my image and now I want to crop ROI again. for example as shown in figure, there is already ROI and the read box which I want cropping. image description

Mat image = roi1(Rect(0, 0, 158, 695)); //ROI for perticulat tubes Rect(0, 76, 158, 545) imshow ("1", Tube1);

I want to do so because I am want to use both of image in my operation. Is there any suggestion how to crop the ROI again. Thank you very much in advance.

2015-11-30 10:26:51 -0600 commented answer how to convert image in rectangle into gray??

Thank you very much for your concern. I am in first step of tube detection. my goal is to capture frame, set ROI for each tubes and than compare with reference frame. As I said I am still learning Image processing and I have got this idea first in my mind so I thought to go with it. but still I have to perform various processes with ROI. As you said, so may be I will try to store a vector of ROIs and perform operation as per requirement. So this is what I can explain. if you need more information I would like to discuss, even its help me too to improve my knowledge.

2015-11-30 09:46:39 -0600 answered a question how to convert image in rectangle into gray??

This problem is solved on stack overflow by MIKI.

image description

#include <opencv2\opencv.hpp>
using namespace cv;

int main()
{
    // Your image
    Mat3b img = imread("path_to_image");

    // Your rects
    vector<Rect> rois{ Rect(50, 50, 200, 300), Rect(400, 100, 200, 380) };

    for (int i = 0; i < rois.size(); ++i)
    {
        // Convert each roi to grayscale
        Mat crop = img(rois[i]).clone();      // Crop is color CV_8UC3
        cvtColor(crop, crop, COLOR_BGR2GRAY); // Now crop is grayscale CV_8UC1
        cvtColor(crop, crop, COLOR_GRAY2BGR); // Now crop is grayscale, CV_8UC3
        crop.copyTo(img(rois[i]));            // Copy grayscale CV_8UC3 into color image
    }

    // Show results
    imshow("Result", img);
    waitKey();

    return 0;
}
2015-11-30 03:20:30 -0600 commented question how to convert image in rectangle into gray??

hello, I want to perform operation in the same image. Thank you very much.

2015-11-29 09:14:25 -0600 commented question how to convert image in rectangle into gray??

Thank you very much for suggestion. I tried with following code, But still I am not getting the result. Mat OI = imread("C:/Users/ankit/Desktop/New folder/2/cam2.png", 1);

Mat roi2 = OI.clone();
for (int i = 612; i >= 0; i = i-204) { cout << "i" << i << endl; Mat roi2 = OI(Rect(i, 0, 161, 643)); rectangle( OI, Rect(i, 0, 161, 643), 1, 2, 8, 0 );

cvtColor(roi2, roi2, CV_BGR2GRAY );
}

imshow("Display window",roi2);

if possible then please provide me simple code or suggestion again.

Thank you very much once again.

2015-11-28 16:50:08 -0600 asked a question how to convert image in rectangle into gray??

Hello,

I am looking for logic or suggestions regarding to access the or do various operations with selected rectangles from the image. for example in given image I am able to draw rectangle by using rectangle function but I want to convert the selected rectangle parts into gray scale or to find the non zero element values for it.

image description

for (int i = 612; i >= 0; i = i-204)
{

cout << "i" << i << endl;

rectangle( roi1, Rect(i, 0, 161, 643),  (255, 255,255), 2, 8, 0 );//add this line to draw contour on main screen

}

imshow( "Display window", roi1 );

Is there any suggestions how can I do so?

Thank you very much in advance.

Regards.

2015-11-27 04:49:58 -0600 asked a question How to draw the bounding box for ROI?

Hello,

Here is my image and I want to draw rectangle around each tube in the image.distance between two tubes is around 200 pixels and for example first tube from the right is Rect(612, 0, 161, 643).

is there any suggestions how can I draw rectangle around the each tube so during the processes I can only considered the rectangle part. I am using this command for drawing rectangle for first tube, rectangle( image, Rect(612, 0, 161, 643), (0, 255,255), 2, 8, 0 );

Thank you very much in advance.

Regards.

2015-10-27 09:21:03 -0600 received badge  Teacher (source)
2015-10-10 02:48:39 -0600 marked best answer why the captured image from code is not bright as normal captured image?

Hello,

I am facing one problem regarding the capturing image from the USB camera. when I captured image without using coding i.e. directly from the camera than its give me bright image. but when i took image from capture image code from opencv than same image from same camera looks very dark.

what should be the probably reasons for this?? and i am using normal capture camera code only from tutorial. please guide me. waiting for suggestions.

Thank you very much in advance.

2015-08-24 05:30:29 -0600 answered a question how to detect colors precisely ?

sample tume images

camera capture one tube at a time,

tube should be like this or any other view like some time barcode is visible in frame or some time its not visible

and some time frame is without tube,

image description

I am looking for logic to have an idea that whether tube is present or not in the frame. as in my case there are different back ground, other wise image subtraction was working good to check the equality of images.

Is there any suggestion for detecting the presence of tube.

Thank you very much in advance.

2015-08-05 02:31:33 -0600 commented question how to detect colors precisely ?

Thank you for comments. there is only one tube at a time, this is just sample picture with multiple tubes with different filling. I will try according to your suggestion.

2015-08-04 02:12:36 -0600 commented question how to detect colors precisely ?

thank you for comments, actually I am looking for the contents of the tubes.

2015-08-03 10:20:14 -0600 asked a question how to detect colors precisely ?

Hello,

I want to detect the color from the tube, I am using In range function and HSV plan , its work fine for one by one tube,but as shown in figure, all tube has not exactly same color. image description

is there any way to detect this color with minimum error. Please give me any suggestion how can I do color detection precisely.

Thank you very much in advance.

2015-07-31 04:38:26 -0600 marked best answer how to get desired line in the frame or measure the distance between two line?

hello,

I an using this code for hough line

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

using namespace cv;
using namespace std;
Mat frame;
int main()
{
   Mat src = imread("building.jpg", 0); 

    Mat dst, cdst;

    Canny(src, dst, 50, 200, 3); 
    cvtColor(dst, cdst, CV_GRAY2BGR); 

    vector<Vec2f> lines;
    // detect lines
    HoughLines(dst, lines, 1, CV_PI/180, 150, 0, 0 );

    // draw lines
    for( size_t i = 0; i < lines.size(); i++ )
    {

        float rho = lines[i][0], theta = lines[i][1];

                if( theta>CV_PI/180*170 || theta<CV_PI/180*10)
        {
        Point pt1, pt2;

        double a = cos(theta), b = sin(theta);
        double x0 = a*rho, y0 = b*rho;

        pt1.x = cvRound(x0 + 1000*(-b));
        pt1.y = cvRound(y0 + 1000*(a));
        pt2.x = cvRound(x0 - 1000*(-b));
        pt2.y = cvRound(y0 - 1000*(a));


        line( src, pt1, pt2, Scalar(0,0,255), 3, CV_AA);
        }

    }

    imshow("source", src;
    imshow("detected lines", cdst);

    waitKey();
    return 0;
}

I want line aroung the tube only and other i don't want.image description the width of tube is aroung 46 pixel, from the frame. is there any suggestions how to detect the desired line.

Thank you very much in advance.

2015-07-31 04:38:23 -0600 received badge  Student (source)
2015-07-30 09:50:19 -0600 commented question getting error to compare one image with multiple images.

Thank you for comment, initialized means to assigned int val = 0, val1 = 0, val2 = 0, val3 = 0, val4= 0 ; that also I tried, but still not getting result.

2015-07-30 09:09:48 -0600 asked a question getting error to compare one image with multiple images.

Hello, I am trying to compare one reference image with other images, I know the reference images, so I just want to compare current image with it to check whether they matched or not. I simply used else if statement, but somehow result is not correct. here is my code,

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <string>

using namespace cv;
using namespace std;

     Mat result, result1, result2, result3, result4;
     Mat frame;
     int val, val1, val2, val3, val4 ;

int main()
{


     frame = imread("C:\\Users\\ankit\\Desktop\\test\\new system\\5.png", 1);
     cvtColor( frame, frame, CV_RGB2GRAY );
     imshow("newframe", frame);


     Mat reference= imread("C:\\Users\\ankit\\Desktop\\test\\new system\\1.png", 1); 
     cvtColor( reference, reference, CV_RGB2GRAY );
     absdiff(reference, frame, result);
    /* threshold( result, result, 120, 255, THRESH_TOZERO);*/

     val = countNonZero(result);


     if (val < 1000)
     {

        Mat reference1= imread("C:\\Users\\ankit\\Desktop\\test\\new system\\2.png", 1); 
        cvtColor( reference1, reference1, CV_RGB2GRAY );
        absdiff(reference1, frame, result1);
        /*threshold( result1, result1, 120, 255, THRESH_TOZERO);*/
        val1 = countNonZero(result1);
        cout << "matched 1  " <<  endl;
     }
     else if( val1 < 1000)
         {

             Mat reference2= imread("C:\\Users\\ankit\\Desktop\\test\\new system\\3.png", 1); 
             cvtColor( reference2, reference2, CV_RGB2GRAY );
             absdiff(reference2, frame, result2);
             /*threshold( result2, result2, 120, 255, THRESH_TOZERO);*/
             val2 = countNonZero(result2);
             cout << "matched 2 " <<   endl;
         }

    else if(val2 < 1000)
    {

        Mat reference3 = imread("C:\\Users\\ankit\\Desktop\\test\\new system\\4.png", 1); 
        cvtColor( reference3, reference3, CV_RGB2GRAY );
        absdiff(reference3, frame, result3);
        /*threshold( result3, result3, 120, 255, THRESH_TOZERO);*/
        val3 = countNonZero(result3);
        cout << "matched 3 " <<  endl;
    }

    else if (val3 < 1000)
        {

            Mat reference4= imread("C:\\Users\\ankit\\Desktop\\test\\new system\\5.png", 1); 
            cvtColor( reference4, reference4, CV_RGB2GRAY );
            absdiff(reference4, frame, result4);
            /*threshold( result4, result4, 120, 255, THRESH_TOZERO);*/

            val4 = countNonZero(result4);  
            cout << "matched 4 " <<  endl;
        }


    else if (val4 < 1000)
        {
        cout << "matched 5" << endl;
        }

    else
    {
    cout << "not matched" << endl;
    }

     waitKey(0);
     return 0;
}

I just want to display the result that image matched or not. but I am not getting proper result. is there any suggestions that where I am doing wrong ? Please guide me.

Thank you very much in advance.

2015-07-28 03:28:13 -0600 commented question how to detect whether tube is present of not??

Thank you very much for suggestions, I tried with you suggestion, but I think there is something need to change in if statement, because it always give the same result whether value is near to 0 or not. So currently I am taking the nonzero value in account, in order to do comparison. Thank you very much once again.

2015-07-27 10:16:27 -0600 commented question how to detect whether tube is present of not??

thank you for your suggestion. you are right,i am getting lots of noise and because of it i am not getting correct non- zero elements value. in my case I have fix lightning condition, but still I am not getting correct result. doing threshold on the difference means using this instruction or threshold( src, dst, 100, 255, 0 ); please explain me how can i do it, as I have no much idea regarding to this.I am using this absdiff(reference, frame, result1); int val = countNonZero(result1); and then compare the value, but can you please guide me how can I do threshold and get accurate result. Thank you very much for all your suggestions and time.-

2015-07-22 02:17:53 -0600 commented answer why the captured image from code is not bright as normal captured image?

I tried the code... but there is not big changes between two frames. But its give time to the camera to set the auto focus before capturing the image.