mardi 3 mars 2015

Comparing two Points

I want to compare two points, if one point is in a specific area it should generate another, somehow my program doesn't do this... This is just a part of it...


my imports:



import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
import org.opencv.core.Mat;
import org.opencv.core.MatOfByte;
import org.opencv.core.Point;
import org.opencv.highgui.Highgui;


My method:



public void drawMiddle(Graphics2D g) {
g.setColor(Color.ORANGE);
targetPoint = new Point(1080/2, 768/2);
g.fillOval((int) targetPoint.x-5, (int)targetPoint.y-5, radius*2, radius*2);

if((faceCenter.x > targetPoint.x-5 && faceCenter.x < targetPoint.x +5)&&(faceCenter.y > targetPoint.y-5 && faceCenter.y < targetPoint.y +5)){
System.out.println("MATCH");
// targetPoint random generieren
targetPoint = new Point(Math.random()*1000+100, Math.random()*700+100);
repaint();
}


}


If you need any other informations pls let me know :)





Aucun commentaire:

Enregistrer un commentaire