Jon Storm
Jon Storm

Reputation: 185

Looking to create a bot for an online java based game

I am currently doing research on how I am going to do this.

I need a program to read the screen of my computer(pixels, edges, etc) and an answer that I think might work is opencv. However everything I look into about opencv reads from a video camera and not from a computer screen. Is it possible to record the screen and use it in the same fashion that I see video cameras being used in opencv?

If so can anyone point me to some reading on this? So far I havent found any examples that apply to what I am looking for

EDIT: I am not looking for anybody to write code for me. Im simply asking if it is possible to use the screen as a video feed for opencv. I am not familiar with opencv nor have I ever used it before.

Upvotes: 0

Views: 1515

Answers (1)

RyanfaeScotland
RyanfaeScotland

Reputation: 1213

Does the system have to use OpenCV and C++? I know that Java can do this very easily using its built it Robot class the code being:

 try {
    Robot robot = new Robot();
Rectangle captureSize = new Rectangle(0, 0, 500, 500);
    BufferedImage bufferedImage = robot.createScreenCapture(captureSize);
}
catch(AWTException e) {
    System.err.println("Error");
}

If you really want to use OpenCV and C++ you could connect to them via JNI but this would probably be making life harder than it needs to be.

Upvotes: 1

Related Questions