Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

getting the most prominent green object in the scene

I am trying to recognize pedestrian traffic signal.I am converting the image to HSV color space, then applying in-range function to get only green lights.

This is my code..

  public void onManagerConnected(int status) {
                switch (status) {
                    case LoaderCallbackInterface.SUCCESS:
                    {
                        Log.i(TAG, "OpenCV loaded successfully...................");
                        Mat img = null;
                        try {
                            img = Utils.loadResource(getBaseContext(), R.drawable.glarrygreen, Highgui.CV_LOAD_IMAGE_COLOR);
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        Mat mHSV = new Mat();
                        Mat mRgba2=new Mat();
                        Mat mHSVThreshed=new Mat();
                        Imgproc.cvtColor(img, mHSV, Imgproc.COLOR_BGR2HSV,3);
                      //This works for red lights
                         Core.inRange(mHSV, new Scalar(0, 64, 200), new Scalar(69, 255, 255), mHSVThreshed);
                        //this works for green lights
                        Core.inRange(mHSV, new Scalar(85, 64, 200), new Scalar(170, 255, 255), 

                                mHSVThreshed);
                        Imgproc.cvtColor(mHSVThreshed, img, Imgproc.COLOR_GRAY2BGR, 0);
                        Imgproc.cvtColor(img, mRgba2, Imgproc.COLOR_BGR2RGBA, 0);
                        Bitmap bmp = Bitmap.createBitmap(img.cols(), img.rows(), Bitmap.Config.ARGB_8888);
                        Utils.matToBitmap(mRgba2, bmp);
                        }
                }
        }

Here is my input and output images![image description](/upfiles/1410855601394358.jpg)

Now I need to filter out other green signals in the scene.How do I do this?How do I get the most prominent green signal in the scene.

image description

getting the most prominent green object in the scene

I am trying to recognize pedestrian traffic signal.I am converting the image to HSV color space, then applying in-range function to get only green lights.

This is my code..

  public void onManagerConnected(int status) {
                switch (status) {
                    case LoaderCallbackInterface.SUCCESS:
                    {
                        Log.i(TAG, "OpenCV loaded successfully...................");
                        Mat img = null;
                        try {
                            img = Utils.loadResource(getBaseContext(), R.drawable.glarrygreen, Highgui.CV_LOAD_IMAGE_COLOR);
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        Mat mHSV = new Mat();
                        Mat mRgba2=new Mat();
                        Mat mHSVThreshed=new Mat();
                        Imgproc.cvtColor(img, mHSV, Imgproc.COLOR_BGR2HSV,3);
                      //This works for red lights
                         Core.inRange(mHSV, new Scalar(0, 64, 200), new Scalar(69, 255, 255), mHSVThreshed);
                        //this works for green lights
                        Core.inRange(mHSV, new Scalar(85, 64, 200), new Scalar(170, 255, 255), 

                                mHSVThreshed);
                        Imgproc.cvtColor(mHSVThreshed, img, Imgproc.COLOR_GRAY2BGR, 0);
                        Imgproc.cvtColor(img, mRgba2, Imgproc.COLOR_BGR2RGBA, 0);
                        Bitmap bmp = Bitmap.createBitmap(img.cols(), img.rows(), Bitmap.Config.ARGB_8888);
                        Utils.matToBitmap(mRgba2, bmp);
                        }
                }
        }

Here is my input and output images![image description](/upfiles/1410855601394358.jpg)

images

image description

Now I need to filter out other green signals in the scene.How do I do this?How do I get the most prominent green signal in the scene.

image description

click to hide/show revision 3
editing text

getting the most prominent green object in the scene

I am trying to recognize pedestrian traffic signal.I am converting the image to HSV color space, then applying in-range function to get only green lights. lights.

This is my code.. code:

public void onManagerConnected(int status) {
    switch (status) {
       case LoaderCallbackInterface.SUCCESS:
       {
          Log.i(TAG, "OpenCV loaded successfully...................");
          Mat img = null;
          try {
             img = Utils.loadResource(getBaseContext(), R.drawable.glarrygreen, Highgui.CV_LOAD_IMAGE_COLOR);
          } catch (IOException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
          }
          Mat mHSV = new Mat();
          Mat mRgba2=new Mat();
          Mat mHSVThreshed=new Mat();
          Imgproc.cvtColor(img, mHSV, Imgproc.COLOR_BGR2HSV,3);
          //This works for red lights
          Core.inRange(mHSV, new Scalar(0, 64, 200), new Scalar(69, 255, 255), mHSVThreshed);
          //this works for green lights
          Core.inRange(mHSV, new Scalar(85, 64, 200), new Scalar(170, 255, 255),  mHSVThreshed);
          Imgproc.cvtColor(mHSVThreshed, img, Imgproc.COLOR_GRAY2BGR, 0);
          Imgproc.cvtColor(img, mRgba2, Imgproc.COLOR_BGR2RGBA, 0);
          Bitmap bmp = Bitmap.createBitmap(img.cols(), img.rows(), Bitmap.Config.ARGB_8888);
          Utils.matToBitmap(mRgba2, bmp);
       }
    }
 }
 

Here is my input and output images

image description

Now I need to filter out other green signals in the scene.How do I do this?How do I get the most prominent green signal in the scene.

scene.

image description