Ask Your Question

ChukZ's profile - activity

2020-08-22 16:16:41 -0600 received badge  Famous Question (source)
2020-04-08 06:31:55 -0600 received badge  Popular Question (source)
2019-04-16 10:19:21 -0600 marked best answer Detecting shapes using opencv with Java

How can i find straight line, square, circle, polygon, angle, arc, vertical line, inter-circle distance, 4 point angle etc. using opencv and java. How can i start this.Please guide me.

2019-04-01 01:06:11 -0600 received badge  Notable Question (source)
2018-09-02 05:31:01 -0600 received badge  Popular Question (source)
2017-11-16 03:38:43 -0600 commented question How to detect arc using opencv java

Imgproc.cvtColor(src, gray, Imgproc.COLOR_BGR2GRAY); Imgproc.medianBlur(gray, gray, 5); Mat binary = new Mat(); //

2017-11-16 03:16:25 -0600 answered a question Detecting rectangle on android

This one worked for me. DetectingShapes

2017-11-15 06:05:37 -0600 commented question How to detect arc using opencv java

@berak. Thank You for your support. Here I am sending the original image. Images

2017-11-15 05:58:22 -0600 commented question How to detect arc using opencv java

Yes @berak outline of the green arc.

2017-11-15 05:57:10 -0600 commented question How to detect arc using opencv java

Yes @berak outline of the green arc.

2017-11-15 05:49:21 -0600 commented question How to detect arc using opencv java

for (Point cntt : cnt.toArray()) { //Drawing a Circle Imgproc.circle( sr

2017-11-15 05:48:55 -0600 commented question How to detect arc using opencv java

for (Point cntt : cnt.toArray()) { //Drawing a Circle Imgproc.circle( src, cntt,

2017-11-15 05:32:11 -0600 commented question How to detect arc using opencv java

Imgproc.circle ( gray, cnt.toArray(), 100, new Scalar

2017-11-15 04:55:02 -0600 commented question How to detect arc using opencv java

hierarchyOutputVector = new Mat(); List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); Imgproc.findCon

2017-11-15 03:52:28 -0600 edited question How to detect arc using opencv java

How to detect arc using opencv java System.loadLibrary(Core.NATIVE_LIBRARY_NAME); FileChooser fileChooser =

2017-11-15 03:52:00 -0600 edited question How to detect arc using opencv java

How to detect arc using opencv java System.loadLibrary(Core.NATIVE_LIBRARY_NAME); FileChooser fileChooser = new

2017-11-15 01:49:20 -0600 asked a question How to detect arc using opencv java

How to detect arc using opencv java How to detect arc of a given image using opencv and java. It will be very useful if

2017-11-13 11:05:31 -0600 marked best answer Shape detection using opencv and java

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {

  // get the camera frame as gray scale image
  Mat gray = null;

  if (DETECT_RED_OBJECTS_ONLY)
  {
   gray = inputFrame.rgba();
  } 
  else 
  {
   gray = inputFrame.gray();
  }


  // the image to output on the screen in the end
  // -> get the unchanged color image
  Mat dst = inputFrame.rgba();

Here code is used ----org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame; But i want to do something like this.I want to convert this android code to opencv java

 public static Mat onCameraFrame(Mat inputFrame) {

    Mat gray = null;
if (DETECT_RED_OBJECTS_ONLY) {
    gray = inputFrame.rgba();
} else {
    gray = inputFrame.gray();
}


// the image to output on the screen in the end
// -> get the unchanged color image
Mat dst = inputFrame.rgba();

now there is no such a thing rgba() & gray().

Please anyone help me to solve this

2017-11-13 01:37:48 -0600 edited question findContours in opencv Java

findContours in opencv Java if (DETECT_RED_OBJECTS_ONLY) { Imgproc.cvtColor(inputFrame, gray, Imgproc.COLOR_

2017-11-13 01:18:23 -0600 edited question findContours in opencv Java

findContours in opencv Java if (DETECT_RED_OBJECTS_ONLY) { Imgproc.cvtColor(inputFrame, gray, Imgproc.COLOR_

2017-11-13 01:17:22 -0600 edited question findContours in opencv Java

findContours in opencv Java if (DETECT_RED_OBJECTS_ONLY) { Imgproc.cvtColor(inputFrame, gray, Imgproc.COLOR_BGR2

2017-11-13 01:16:32 -0600 edited question findContours in opencv Java

findContours in opencv Java if (DETECT_RED_OBJECTS_ONLY) { Imgproc.cvtColor(inputFrame, gray, Imgproc.COLOR_BGR2

2017-11-13 00:37:38 -0600 asked a question findContours in opencv Java

findContours in opencv Java if (DETECT_RED_OBJECTS_ONLY) { Imgproc.cvtColor(inputFrame, gray, Imgproc.COLOR_BGR2RGB)

2017-11-12 22:46:42 -0600 commented answer Shape detection using opencv and java

Mat gray = null; if (DETECT_RED_OBJECTS_ONLY) { Imgproc.cvtColor(inputFrame, gray, Imgproc.COLOR_BGR2RGB

2017-11-12 22:44:56 -0600 commented answer Shape detection using opencv and java

Mat gray = null; if (DETECT_RED_OBJECTS_ONLY) { Imgproc.cvtColor(inputFrame, gray, Imgproc.COLOR_BGR2RGB

2017-11-12 22:43:59 -0600 commented answer Shape detection using opencv and java

Mat gray = null; if (DETECT_RED_OBJECTS_ONLY) { Imgproc.cvtColor(inputFrame, gray, Imgproc.COLOR_BGR2RGB);

2017-11-08 22:02:17 -0600 edited question Shape detection using opencv and java

Shape detection using opencv and java public Mat onCameraFrame(CvCameraViewFrame inputFrame) { // get the camera fram

2017-11-08 22:00:53 -0600 commented question Shape detection using opencv and java

@eshirima OK understood. Now I have edited my question.

2017-11-08 22:00:01 -0600 commented question Shape detection using opencv and java

OK understood. Now I have edited my question.

2017-11-08 21:58:50 -0600 edited question Shape detection using opencv and java

Shape detection using opencv and java public Mat onCameraFrame(CvCameraViewFrame inputFrame) { // get the camera fram

2017-11-08 21:58:11 -0600 edited question Shape detection using opencv and java

Shape detection using opencv and java Input image : image I have developed some code looking at another code. I am usin

2017-11-08 06:07:33 -0600 edited question Shape detection using opencv and java

Shape detection using opencv and java import org.opencv.core.; import org.opencv.core.Point; import org.

2017-11-08 06:06:09 -0600 edited question Shape detection using opencv and java

Shape detection using opencv and java import org.opencv.core.; import org.opencv.core.Point; import org.opencv.i

2017-11-08 01:11:20 -0600 edited question Shape detection using opencv and java

Shape detection using opencv and java import org.opencv.core.*; import org.opencv.core.Point; import org.opencv.

2017-11-08 00:54:29 -0600 asked a question Shape detection using opencv and java

Shape detection using opencv and java import org.opencv.core.*; import org.opencv.core.Point; import org.opencv.imgcode

2017-11-02 04:30:35 -0600 commented answer Is openCv compatible with multiple Cameras???

Thank You I have learnt a lot of thing

2017-11-02 04:26:13 -0600 marked best answer Is openCv compatible with multiple Cameras???

This code is workable. method 1 returns colored frame while method 2 returns binary frames.Although i initialized two cameras , I am still thinking that this program does not run with two cameras.It is using only one camera. Am i right ?? or wrong??

 @FXML
    public void mcamera(ActionEvent ee){

        new Thread(() -> method1()).start();
        new Thread(() -> method2()).start();
    }




    public void method1() {
       VideoCapture camera1 = new VideoCapture("/home/chinthaka/Downloads/wow/giphy.mp4");
        if (!camera1.isOpened()) {
            System.out.println("Error! Camera can't be opened!");
            return;
        }


        Mat frame = new Mat();

        while (true) {
            if (camera1.read(frame)) {
                System.out.println("Frame Obtained");
                System.out.println("Captured Frame Width " +
                        frame.width() + " Height " + frame.height());
                Imgcodecs.imwrite("camera.jpg", frame);
                System.out.println("OK");


                while (camera1.read(frame)) {
                    System.out.println("Frame Obtained");
                    System.out.println("Captured Frame Width " +
                            frame.width() + " Height " + frame.height());
                    Imgcodecs.imwrite("camera.jpg", frame);
                    System.out.println("OK");





                    bufferedImage = matToBufferedImage(frame);


                    showWindow(bufferedImage);
                }

                camera1.release();

                break;


            }
        }

    }
    public void method2() {
        VideoCapture camera2 = new VideoCapture("/home/chinthaka/Downloads/wow/cinnamon.mp4");
        if (!camera2.isOpened()) {
            System.out.println("Error! Camera can't be opened!");
            return;
        }

        Mat frame = new Mat();


        while (true) {
            if (camera2.read(frame)) {
                System.out.println("Frame Obtained");
                System.out.println("Captured Frame Width " +
                        frame.width() + " Height " + frame.height());
                Imgcodecs.imwrite("camera.jpg", frame);
                System.out.println("OK");


                while (camera2.read(frame)) {
                    System.out.println("Frame Obtained");
                    System.out.println("Captured Frame Width " +
                            frame.width() + " Height " + frame.height());
                    Imgcodecs.imwrite("camera.jpg", frame);
                    System.out.println("OK");


                    //convert original color frame into gray scale frame.
                    Imgproc.cvtColor(frame, frame, Imgproc.COLOR_BGR2GRAY);

                    //convert gray scale frame to binary frame.
                    threshold(frame, frame, 100, 255, THRESH_BINARY);

                    bufferedImage = matToBufferedImage(frame);
                    showWindow(bufferedImage);


                }

                camera2.release();

                break;


            }
        }
    }
2017-11-02 04:24:56 -0600 commented answer Is openCv compatible with multiple Cameras???

VideoCapture camera1 = new VideoCapture(0); That means if we use file path instead of 0 ,1 in videocapture , there is

2017-11-02 04:24:20 -0600 commented answer Is openCv compatible with multiple Cameras???

VideoCapture camera1 = new VideoCapture(**0**); That means if we use file path instead of 0 ,1 in videocapture , there

2017-11-02 02:47:47 -0600 edited question Is openCv compatible with multiple Cameras???

Is openCv compatible with multiple Cameras??? This code is workable. method 1 returns colored frame while method 2 retur

2017-11-02 02:45:57 -0600 commented question Is openCv compatible with multiple Cameras???

Thank you @berak for your comment. but this post---your comment-----you have done something like above.Isn't it??. post

2017-11-02 02:35:24 -0600 edited question Is openCv compatible with multiple Cameras???

Is openCv compatible with multiple Cameras??? This code is workable. method 1 returns colored frame while method 2 retur

2017-11-02 02:34:06 -0600 edited question Is openCv compatible with multiple Cameras???

Is openCv compatible with multiple Cameras??? This code is workable. method 1 returns colored frame while method 2 retur

2017-11-02 01:47:58 -0600 asked a question Is openCv compatible with multiple Cameras???

Is openCv compatible with multiple Cameras??? This code is workable. method 1 returns colored frame while method 2 retur

2017-11-02 00:02:00 -0600 marked best answer Binarization of real-time video

Here I have implemented the code. It extract frames from a video ,converts each frame to grayscale ---threshold ---binary and outputs. But it outputs frames one by one .I want to add extracted binary frames together and output a complete video in black and white. How to add frames to output a video???.

@FXML
public void takeframesbyframes(ActionEvent e) {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    String filePath = "/home/chinthaka/Downloads/wow/giphy.mp4";
    if (!Paths.get(filePath).toFile().exists()) {
        System.out.println("File " + filePath + " does not exist!");
        return;
    }
    VideoCapture camera = new VideoCapture(filePath);
    if (!camera.isOpened()) {
        System.out.println("Error! Camera can't be opened!");
        return;
    }
    Mat frame = new Mat();
    while (true) {
        if (camera.read(frame)) {
            System.out.println("Frame Obtained");
            System.out.println("Captured Frame Width " +
                    frame.width() + " Height " + frame.height());
            Imgcodecs.imwrite("camera.jpg", frame);
            System.out.println("OK");
            while (camera.read(frame)) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
                System.out.println("Frame Obtained");
                System.out.println("Captured Frame Width " +
                        frame.width() + " Height " + frame.height());
                Imgcodecs.imwrite("camera.jpg", frame);
                System.out.println("OK");

                //convert original color frame into gray scale frame.
                Imgproc.cvtColor(frame, frame, Imgproc.COLOR_BGR2GRAY);

                //convert gray scale frame to binary frame.
                threshold(frame, frame, 100, 255, THRESH_BINARY);

                bufferedImage = matToBufferedImage(frame);
                showWindow(bufferedImage);
                Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
                alert.setTitle("Extracting Frames");
                alert.setHeaderText("You are in a process.");
                alert.setContentText("Do you want to get next frame!!!");
                Optional<ButtonType> result = alert.showAndWait();
                if (result.get() == ButtonType.OK) {
                    alert.hide();
                } else {
                    break;
                }
            }
            camera.release();
            break;
        }
    }
}
private static BufferedImage matToBufferedImage(Mat frame) {
    int type = 0;
    if (frame.channels() == 1) {
        type = BufferedImage.TYPE_BYTE_GRAY;
    } else if (frame.channels() == 3) {
        type = BufferedImage.TYPE_3BYTE_BGR;
    }
    BufferedImage image = new BufferedImage(frame.width(), frame.height(), type);
    WritableRaster raster = image.getRaster();
    DataBufferByte dataBuffer = (DataBufferByte) raster.getDataBuffer();
    byte[] data = dataBuffer.getData();
    frame.get(0, 0, data);
    return image;
}
private void showWindow(BufferedImage img) {
    JFrame frame = new JFrame();
    frame.getContentPane().add(new JLabel(new ImageIcon(img)));
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.setSize(img.getWidth(), img.getHeight() + 100);
    frame.setTitle("Image captured");
    frame.setVisible(true);
}
2017-11-02 00:01:48 -0600 commented answer Binarization of real-time video

If we use following thing can i use false in VideoWriter writer = new VideoWriter("my.avi",