ACT-CV - Machine Vision for Cognitive Modeling
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
Robot.h
Go to the documentation of this file.
1
// -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; coding: iso-8859-1; -*-
2
3
/*
4
ACT-CV - Machine Vision for Cognitive Modeling
5
Copyright (c) 2008 Marc Halbruegge
6
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
11
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
29
#ifndef ROBOT_H_
30
#define ROBOT_H_
31
32
#ifdef HAVE_CONFIG_H
33
#include <
config.h
>
34
#endif
35
36
#include <
mhexcptn.h
>
37
38
#include <
java/JVM.h
>
39
40
#include <cv.h>
41
50
class
Robot
:
public
JVM
{
51
53
jclass
cls
;
55
jobject
robot
;
56
58
jclass
colorCls
;
59
61
jclass
rectCls
;
63
jmethodID
initRectMID
;
64
65
protected
:
67
int
screenWidth
;
69
int
screenHeight
;
70
72
jobject
CreateRect
(
int
x,
int
y,
int
width,
int
height) {
73
jobject result =
GetEnv
()->NewObject(
rectCls
,
initRectMID
,
74
x,y,width,height);
75
if
(result ==
nullptr
)
throw
LineException
(__LINE__);
76
return
result;
77
}
78
80
jobject
CreateScreenRect
();
81
82
public
:
84
Robot
();
86
~Robot
();
87
88
int
GetScreenWidth
()
const
{
89
return
screenWidth
;
90
}
91
int
GetScreenHeight
()
const
{
92
return
screenHeight
;
93
}
94
95
void
AttachCurrentThread
() {
96
JVM::AttachCurrentThread
();
97
}
98
void
DetachCurrentThread
() {
99
JVM::DetachCurrentThread
();
100
}
101
private
:
102
jmethodID
setAutoDelayMID
;
103
public
:
105
void
SetAutoDelay
(
int
ms) {
106
GetEnv
()->CallVoidMethod(
robot
,
setAutoDelayMID
, ms);
107
}
108
109
private
:
110
jmethodID
delayMID
;
111
public
:
113
void
Delay
(
int
ms) {
114
GetEnv
()->CallVoidMethod(
robot
,
delayMID
, ms);
115
}
116
117
private
:
118
jmethodID
mouseMoveMID
;
119
public
:
121
void
MouseMove
(
int
x,
int
y) {
122
GetEnv
()->CallVoidMethod(
robot
,
mouseMoveMID
, x, y);
123
}
124
125
126
private
:
127
jmethodID
mousePressMID
;
128
public
:
130
void
MousePress
(
int
buttons) {
131
GetEnv
()->CallVoidMethod(
robot
,
mousePressMID
, buttons);
132
}
133
134
private
:
135
jmethodID
mouseReleaseMID
;
136
public
:
138
void
MouseRelease
(
int
buttons) {
139
GetEnv
()->CallVoidMethod(
robot
,
mouseReleaseMID
, buttons);
140
}
141
142
// keyboard routines -------------------------------------------
143
private
:
144
jmethodID
keyPressMID
;
145
public
:
147
void
KeyPress
(
int
keycode) {
148
GetEnv
()->CallVoidMethod(
robot
,
keyPressMID
, keycode);
149
}
150
151
private
:
152
jmethodID
keyReleaseMID
;
153
public
:
155
void
KeyRelease
(
int
keycode) {
156
GetEnv
()->CallVoidMethod(
robot
,
keyReleaseMID
, keycode);
157
}
158
159
private
:
160
jmethodID
getPixelColorMID
;
161
jmethodID
getRGBMID
;
162
public
:
171
int
GetPixelRGB
(
int
x,
int
y);
172
173
private
:
174
jmethodID
createScreenCaptureMID
;
175
jclass
bufrImgCls
;
176
jmethodID
getRGBArrMID
;
177
public
:
190
IplImage*
GetScreenCapture
(
int
left,
int
top,
int
right,
int
bottom);
191
};
192
193
194
#endif
/*ROBOT_H_*/
ACT-CV - Machine Vision for Cognitive Modeling
© 2015
Marc Halbruegge
(actcvlibrary@googlemail.com)