Javacv: Adding mouse tracking in the Square Demo class

Created on 29 May 2018  路  2Comments  路  Source: bytedeco/javacv

Hello,

I'm trying to create something to measure area and for that I want to be able to retrieve information about cooridnates from the pic.

I'm using Square.java class from your Demo folder.

Could you help me with adding mouse tracking with the MouseOnClickListener ?

I want to be able to retrieve information about position of point that I'm gonna draw on the IplImage ( cause as far as I concern that image is loaded on the CanvasFrame and all the squares are drawn there with the cvPolyLine method).

I was trying to retrieve this information from the canvas but this method returns null constantly....

    while(canvas.isVisible()) { 
             canvas.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent e) {
                        System.out.println(e.getX() + e.getY(););
                    }
                });
        }  

Is there any way to retrieve this coordinates from IplImage (not from the canvas) and be able draw e.q circle on it with a mouse Click event. I tried to add this event everywhere - but with no success tough...

question

All 2 comments

You'll probably need to add it to the Canvas, not the Frame.
Try to call CanvasFrame.getCanvas().addMouseListener(...).

Thank you! That will work for me :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newstarbka picture newstarbka  路  5Comments

chrisliu12345 picture chrisliu12345  路  4Comments

SenudaJayalath picture SenudaJayalath  路  3Comments

iamazy picture iamazy  路  4Comments

kongqw picture kongqw  路  4Comments