Merge lp:~yolanda.robla/ubuntu/saucy/sikuli/debian_merge into lp:ubuntu/saucy/sikuli
- Saucy (13.10)
- debian_merge
- Merge into saucy
Proposed by
Yolanda Robla
Status: | Merged |
---|---|
Merged at revision: | 15 |
Proposed branch: | lp:~yolanda.robla/ubuntu/saucy/sikuli/debian_merge |
Merge into: | lp:ubuntu/saucy/sikuli |
Diff against target: |
11100 lines (+744/-9680) 55 files modified
.pc/applied-patches (+0/-10) .pc/executable-wrappers.patch/sikuli-ide/target/linux/Sikuli-IDE/sikuli-ide.sh (+0/-3) .pc/executable-wrappers.patch/sikuli-script/target/sikuli-script.sh (+0/-2) .pc/fix-cmake-sikuli-ide.patch/sikuli-ide/CMakeLists.txt (+0/-403) .pc/gcc-4.7.patch/sikuli-script/src/main/native/sikuli-debug.h (+0/-52) .pc/install-extension.patch/sikuli-script/src/main/java/org/sikuli/script/ExtensionManager.java (+0/-175) .pc/jgoodies-1.6-compat.patch/sikuli-ide/CMakeLists.txt (+0/-405) .pc/jgoodies-1.6-compat.patch/sikuli-ide/src/main/java/org/sikuli/ide/PreferencesWin.java (+0/-561) .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/Finder.java (+0/-195) .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/TextRecognizer.java (+0/-120) .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/VDictProxy.java (+0/-118) .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/internal/hotkey/LinuxHotkeyManager.java (+0/-106) .pc/native.patch/sikuli-script/src/main/native/vision.i (+0/-264) .pc/no-opencv-surf-module.patch/sikuli-script/src/main/native/cvgui.cpp (+0/-2508) .pc/no-opencv-surf-module.patch/sikuli-script/src/main/native/cvgui.h (+0/-239) .pc/no-opencv-surf-module.patch/sikuli-script/src/main/native/imgdb.cpp (+0/-311) .pc/no-opencv-surf-module.patch/sikuli-script/src/main/native/imgdb.h (+0/-75) .pc/no-opencv-surf-module.patch/sikuli-script/src/main/native/vision.cpp (+0/-506) .pc/no-opencv-surf-module.patch/sikuli-script/src/main/native/vision.h (+0/-118) .pc/no-opencv-surf-module.patch/sikuli-script/src/main/native/vision.i (+0/-264) .pc/tess3.patch/cmake_modules/FindTesseract.cmake (+0/-47) .pc/tess3.patch/sikuli-script/src/main/native/tessocr.cpp (+0/-984) .pc/tessdata.patch/sikuli-script/CMakeLists.txt (+0/-297) .pc/tessdata.patch/sikuli-script/src/main/java/org/sikuli/script/TextRecognizer.java (+0/-118) .pc/tessdata.patch/sikuli-script/src/main/native/tessocr.cpp (+0/-983) .pc/use-java-libs-from-debian.patch/sikuli-ide/CMakeLists.txt (+0/-404) .pc/use-java-libs-from-debian.patch/sikuli-script/CMakeLists.txt (+0/-298) cmake_modules/FindTesseract.cmake (+12/-3) debian/changelog (+36/-0) debian/control (+6/-6) debian/patches/executable-wrappers.patch (+6/-6) debian/patches/force-java6-target.patch (+30/-0) debian/patches/jgoodies-1.6-compat.patch (+0/-40) debian/patches/series (+2/-1) debian/patches/setTextAndMnemonic.patch (+64/-0) debian/rules (+1/-1) sikuli-ide/CMakeLists.txt (+12/-14) sikuli-ide/src/main/java/org/sikuli/ide/PreferencesWin.java (+2/-3) sikuli-ide/target/linux/Sikuli-IDE/sikuli-ide.sh (+2/-1) sikuli-script/CMakeLists.txt (+17/-16) sikuli-script/src/main/java/org/sikuli/script/ExtensionManager.java (+2/-3) sikuli-script/src/main/java/org/sikuli/script/Finder.java (+4/-2) sikuli-script/src/main/java/org/sikuli/script/TextRecognizer.java (+11/-5) sikuli-script/src/main/java/org/sikuli/script/VDictProxy.java (+3/-2) sikuli-script/src/main/java/org/sikuli/script/internal/hotkey/LinuxHotkeyManager.java (+3/-2) sikuli-script/src/main/native/cvgui.cpp (+318/-0) sikuli-script/src/main/native/cvgui.h (+1/-0) sikuli-script/src/main/native/imgdb.cpp (+115/-0) sikuli-script/src/main/native/imgdb.h (+5/-0) sikuli-script/src/main/native/sikuli-debug.h (+1/-1) sikuli-script/src/main/native/tessocr.cpp (+12/-3) sikuli-script/src/main/native/vision.cpp (+63/-0) sikuli-script/src/main/native/vision.h (+5/-0) sikuli-script/src/main/native/vision.i (+10/-4) sikuli-script/target/sikuli-script.sh (+1/-1) |
To merge this branch: | bzr merge lp:~yolanda.robla/ubuntu/saucy/sikuli/debian_merge |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach (community) | Approve | ||
Review via email: mp+176670@code.launchpad.net |
Commit message
Description of the change
Merging from latest Debian version
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed file '.pc/applied-patches' |
2 | --- .pc/applied-patches 2012-12-07 22:13:08 +0000 |
3 | +++ .pc/applied-patches 1970-01-01 00:00:00 +0000 |
4 | @@ -1,10 +0,0 @@ |
5 | -executable-wrappers.patch |
6 | -native.patch |
7 | -use-java-libs-from-debian.patch |
8 | -install-extension.patch |
9 | -fix-cmake-sikuli-ide.patch |
10 | -tess3.patch |
11 | -tessdata.patch |
12 | -gcc-4.7.patch |
13 | -no-opencv-surf-module.patch |
14 | -jgoodies-1.6-compat.patch |
15 | |
16 | === removed directory '.pc/executable-wrappers.patch' |
17 | === removed directory '.pc/executable-wrappers.patch/sikuli-ide' |
18 | === removed directory '.pc/executable-wrappers.patch/sikuli-ide/target' |
19 | === removed directory '.pc/executable-wrappers.patch/sikuli-ide/target/linux' |
20 | === removed directory '.pc/executable-wrappers.patch/sikuli-ide/target/linux/Sikuli-IDE' |
21 | === removed file '.pc/executable-wrappers.patch/sikuli-ide/target/linux/Sikuli-IDE/sikuli-ide.sh' |
22 | --- .pc/executable-wrappers.patch/sikuli-ide/target/linux/Sikuli-IDE/sikuli-ide.sh 2011-04-16 00:23:53 +0000 |
23 | +++ .pc/executable-wrappers.patch/sikuli-ide/target/linux/Sikuli-IDE/sikuli-ide.sh 1970-01-01 00:00:00 +0000 |
24 | @@ -1,3 +0,0 @@ |
25 | -#!/bin/sh |
26 | -DIR=`dirname $0` |
27 | -LC_NUMERIC=C java -Dsikuli.console=true -Dsikuli.debug=0 -Xms64M -Xmx512M -Dfile.encoding=UTF-8 -jar $DIR/sikuli-ide.jar $* |
28 | |
29 | === removed directory '.pc/executable-wrappers.patch/sikuli-script' |
30 | === removed directory '.pc/executable-wrappers.patch/sikuli-script/target' |
31 | === removed file '.pc/executable-wrappers.patch/sikuli-script/target/sikuli-script.sh' |
32 | --- .pc/executable-wrappers.patch/sikuli-script/target/sikuli-script.sh 2011-01-24 01:07:30 +0000 |
33 | +++ .pc/executable-wrappers.patch/sikuli-script/target/sikuli-script.sh 1970-01-01 00:00:00 +0000 |
34 | @@ -1,2 +0,0 @@ |
35 | -#!/bin/sh |
36 | -java -jar sikuli-script.jar $@ |
37 | |
38 | === removed directory '.pc/fix-cmake-sikuli-ide.patch' |
39 | === removed directory '.pc/fix-cmake-sikuli-ide.patch/sikuli-ide' |
40 | === removed file '.pc/fix-cmake-sikuli-ide.patch/sikuli-ide/CMakeLists.txt' |
41 | --- .pc/fix-cmake-sikuli-ide.patch/sikuli-ide/CMakeLists.txt 2011-10-04 23:32:13 +0000 |
42 | +++ .pc/fix-cmake-sikuli-ide.patch/sikuli-ide/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
43 | @@ -1,403 +0,0 @@ |
44 | -# Copyright 2010-2011, Sikuli.org |
45 | -# Released under the MIT License. |
46 | -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) |
47 | -PROJECT (sikuli-ide Java) |
48 | - |
49 | -SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules") |
50 | -INCLUDE(${CMAKE_MODULE_PATH}/common.cmake) |
51 | -INCLUDE(${CMAKE_MODULE_PATH}/detect_osx_ver.cmake) |
52 | -INCLUDE(${CMAKE_MODULE_PATH}/find_dep_libs.cmake) |
53 | - |
54 | - |
55 | -ENABLE_TESTING() |
56 | - |
57 | -SET(CMAKE_VERBOSE_MAKEFILE 0) |
58 | - |
59 | -FIND_PACKAGE(Java 1.6 REQUIRED) |
60 | -SET( NON_NATIVE_TARGET TRUE) |
61 | - |
62 | -IF(UNIX) |
63 | - SET(SEP ":") |
64 | -ELSE() |
65 | - SET(SEP ";") |
66 | -ENDIF() |
67 | - |
68 | - |
69 | -SET(BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") |
70 | -SET(JAVA_SRC_DIR "${BASE_DIR}/src/main/java") |
71 | -SET(NATIVE_SRC_DIR "${BASE_DIR}/src/main/native") |
72 | -SET(COMMON_LIB_DIR "${BASE_DIR}/../lib") |
73 | -SET(INCLUDE_LIB_DIR "${BASE_DIR}/lib") |
74 | -SET(BINARY_DIR "${BASE_DIR}/target") |
75 | -SET(BINARY_CLASS_DIR "${BINARY_DIR}/classes") |
76 | -SET(BINARY_LIB_DIR "${BINARY_DIR}/lib") |
77 | -SET(JAR_DIR "${BINARY_DIR}/jar") |
78 | -SET(RESOURCE_DIR "${BASE_DIR}/resources") |
79 | -SET(RELEASE_DIR "${BASE_DIR}/../release") |
80 | - |
81 | -SET(JAVA_TEST_DIR "${BASE_DIR}/src/test/java") |
82 | -SET(TEST_RESOURCE_DIR "test-res") |
83 | -SET(JAVA_TEST_FOR_HUDSON_XML "../hudson-test.xml") |
84 | -SET(TEST_CLASS_DIR "${CMAKE_BINARY_DIR}/test") |
85 | - |
86 | -SET(SIKULI_SCRIPT_JAR "${COMMON_LIB_DIR}/sikuli-script.jar") |
87 | -SET(JUNIT_JAR "/usr/share/java/junit.jar") |
88 | -SET(SWING_LAYOUT_JAR "/usr/share/java/swing-layout.jar") |
89 | -SET(COMMONS_CLI_JAR "/usr/share/java/commons-cli.jar") |
90 | -SET(JSON_SIMPLE_JAR "/usr/share/java/json_simple.jar") |
91 | -SET(SWINGX_JAR "/usr/share/java/swingx-core.jar") |
92 | -SET(MAC_WIDGETS_JAR "/usr/share/java/mac_widgets.jar") |
93 | -SET(FORMS_JAR "/usr/share/java/forms.jar") |
94 | - |
95 | - |
96 | -FILE(MAKE_DIRECTORY ${BINARY_DIR}) |
97 | -FILE(MAKE_DIRECTORY ${BINARY_CLASS_DIR}) |
98 | -FILE(MAKE_DIRECTORY ${JAR_DIR}) |
99 | -FILE(MAKE_DIRECTORY ${TEST_CLASS_DIR}) |
100 | - |
101 | -## Sikuli IDE |
102 | - |
103 | -SET(MAIN_CLASS org.sikuli.ide.SikuliIDE) |
104 | -SET(RUN_USER_ARGS -Dsikuli.console=true -Dfile.encoding=UTF-8 |
105 | - -Dsikuli.testing=yes |
106 | - -Xms64m -Xmx512m |
107 | - CACHE STRING |
108 | - "The arguments for running Sikuli IDE with 'make run-user'" |
109 | -) |
110 | -SET(RUN_ARGS -Dsikuli.console=false -Dsikuli.Debug=3 -Dfile.encoding=UTF-8 |
111 | - -Dsikuli.testing=yes |
112 | - -Xms64m -Xmx512m |
113 | - #-Duser.language=zh -Duser.region=TW |
114 | - CACHE STRING |
115 | - "The arguments for running Sikuli IDE with 'make run'" |
116 | -) |
117 | -IF(APPLE) |
118 | - LIST(APPEND RUN_ARGS -Xdock:name='Sikuli IDE') |
119 | -ENDIF() |
120 | - |
121 | -#SET(ARGS -s -r ../sample-scripts/mod1.sikuli --args a1 a2) # example args |
122 | -SET(ARGS "") |
123 | - |
124 | -SET(CLASSPATH |
125 | - ${SIKULI_SCRIPT_JAR}${SEP}${JUNIT_JAR}${SEP}${SWING_LAYOUT_JAR}${SEP}${COMMONS_CLI_JAR}${SEP}${JSON_SIMPLE_JAR}${SEP}${SWINGX_JAR}${SEP}${MAC_WIDGETS_JAR}${SEP}${FORMS_JAR}${SEP}/usr/share/java/jython.jar |
126 | -) |
127 | - |
128 | -SET(JAR_FILE sikuli-ide.jar) |
129 | -SET(RESOURCES icons META-INF scripts i18n) |
130 | - |
131 | -IF(LINUX) |
132 | - SET(MANIFEST ${RESOURCE_DIR}/META-INF/MANIFEST-linux.MF) |
133 | - #SET(CLASSPATH ${CLASSPATH}${SEP}${JXGRABKEY_JAR}) |
134 | -ELSEIF(WIN32) |
135 | - SET(MANIFEST ${RESOURCE_DIR}/META-INF/MANIFEST-win32.MF) |
136 | - #SET(CLASSPATH ${CLASSPATH}${SEP}${JINTELLITYPE_JAR}) |
137 | -ELSE() |
138 | - SET(MANIFEST ${RESOURCE_DIR}/META-INF/MANIFEST.MF) |
139 | -ENDIF() |
140 | - |
141 | - |
142 | -add_custom_target( ${JAR_FILE} |
143 | - COMMAND ${JAVA_ARCHIVE} cfm ${BINARY_DIR}/${JAR_FILE} |
144 | - ${MANIFEST} -C ${JAR_DIR} * |
145 | - COMMAND ${CMAKE_COMMAND} -E copy ${BINARY_DIR}/${JAR_FILE} ${COMMON_LIB_DIR}/${JAR_FILE} |
146 | - COMMENT "Packaging ${JAR_FILE}" |
147 | - WORKING_DIRECTORY ${JAR_DIR} |
148 | -) |
149 | - |
150 | -add_custom_target( ${JAR_FILE}.resources |
151 | - COMMAND ${CMAKE_COMMAND} -E copy_directory ${RESOURCE_DIR} ${JAR_DIR} |
152 | - COMMENT "Copying IDE resources" |
153 | -) |
154 | - |
155 | -add_custom_target( ${JAR_FILE}.prepare |
156 | - COMMENT "Preparing ${JAR_FILE}" |
157 | -) |
158 | - |
159 | -add_custom_target( run-user |
160 | - COMMAND ${JAVA_RUNTIME} ${RUN_USER_ARGS} |
161 | - -classpath "${CLASSPATH}${SEP}${JAR_DIR}" |
162 | - ${MAIN_CLASS} ${ARGS} |
163 | -) |
164 | - |
165 | -add_custom_target( run |
166 | - COMMAND ${JAVA_RUNTIME} ${RUN_ARGS} |
167 | - -classpath "${CLASSPATH}${SEP}${JAR_DIR}" |
168 | - ${MAIN_CLASS} ${ARGS} |
169 | -) |
170 | - |
171 | -if(NOT DEFINED SIKULI_VERSION OR SIKULI_VERSION STREQUAL "") |
172 | - file(READ ${BASE_DIR}/latest-ver SIKULI_VERSION) |
173 | - STRING(STRIP ${SIKULI_VERSION} SIKULI_VERSION) |
174 | -ENDIF() |
175 | -message("Sikuli Version ${SIKULI_VERSION}") |
176 | - |
177 | -SET(JYTHON_CLASS org.python.util.jython) |
178 | -add_custom_target( update-version |
179 | - COMMAND ${JAVA_RUNTIME} -cp "${CLASSPATH}" ${JYTHON_CLASS} ${BASE_DIR}/../utils/update-version.py ${JAVA_SRC_DIR}/org/sikuli/ide/IDESettings.java "${SIKULI_VERSION}" |
180 | - COMMENT "Update version number in Sikuli-IDE" |
181 | -) |
182 | - |
183 | -SET(INCLUDE_JARS ${SIKULI_SCRIPT_JAR} ${JUNIT_JAR} |
184 | - ${SWING_LAYOUT_JAR} ${COMMONS_CLI_JAR} |
185 | - ${BINARY_DIR}/${JAR_FILE} ${JSON_SIMPLE_JAR} |
186 | - ${SWINGX_JAR} ${MAC_WIDGETS_JAR} ${FORMS_JAR} |
187 | -) |
188 | - |
189 | -## Windows Package |
190 | - |
191 | -IF(WIN32) |
192 | - SET(OS "win32") |
193 | - SET(APP_FILE "Sikuli-IDE") |
194 | - SET(BINARY_APP_DIR "${BINARY_DIR}/${OS}") |
195 | - SET(JAR_IN_APP_DIR ${BINARY_APP_DIR}/${APP_FILE}) |
196 | - SET(FRAMEWORKS_IN_APP_DIR ${JAR_IN_APP_DIR}/libs) |
197 | - SET(JAR_LIB_DIR ${JAR_DIR}/META-INF/lib) |
198 | - |
199 | - #LIST(APPEND INCLUDE_JARS ${JINTELLITYPE_JAR}) |
200 | - FILE(GLOB sikuli_script_jnilibs "${BASE_DIR}/../sikuli-script/target/lib/*.dll") |
201 | - SET(jnilibs ${sikuli_script_jnilibs}) |
202 | -ENDIF() |
203 | - |
204 | -## Linux Package |
205 | - |
206 | -IF(LINUX) |
207 | - SET(OS "linux") |
208 | - SET(APP_FILE "Sikuli-IDE") |
209 | - SET(BINARY_APP_DIR "${BINARY_DIR}/${OS}") |
210 | - SET(JAR_IN_APP_DIR ${BINARY_APP_DIR}/${APP_FILE}) |
211 | - SET(FRAMEWORKS_IN_APP_DIR ${JAR_IN_APP_DIR}/libs) |
212 | - SET(JAR_LIB_DIR ${JAR_DIR}/META-INF/lib) |
213 | - |
214 | - #LIST(APPEND INCLUDE_JARS ${JXGRABKEY_JAR}) |
215 | - SET(jnilibs "") |
216 | - FILE(GLOB sikuli_script_jnilibs "${BASE_DIR}/../sikuli-script/target/lib/*.so") |
217 | - LIST(APPEND jnilibs ${sikuli_script_jnilibs}) |
218 | -ENDIF(LINUX) |
219 | - |
220 | -## Sikuli-IDE.App for Mac OS X |
221 | - |
222 | -IF(APPLE) |
223 | - IF(APPLE_SNOW_LEOPARD) |
224 | - SET(OSX_VER "osx-10.6") |
225 | - ELSEIF(APPLE_LEOPARD) |
226 | - SET(OSX_VER "osx-10.5") |
227 | - ENDIF() |
228 | - SET(OS ${OSX_VER}) |
229 | - |
230 | - SET(APP_FILE "Sikuli-IDE.app") |
231 | - SET(BINARY_APP_DIR "${BINARY_DIR}/${OS}") |
232 | - SET(JAR_IN_APP_DIR ${BINARY_APP_DIR}/${APP_FILE}/Contents/Resources/Java) |
233 | - SET(FRAMEWORKS_IN_APP_DIR ${BINARY_APP_DIR}/${APP_FILE}/Contents/Frameworks) |
234 | - |
235 | - FIND_PACKAGE(OpenCV REQUIRED) |
236 | - #message("opencv lib: ${OpenCV_LIB_DIR}") |
237 | - LIST(APPEND CMAKE_LIBRARY_PATH ${OpenCV_LIB_DIR}) |
238 | - |
239 | - FILE(GLOB jnilibs "${BINARY_LIB_DIR}/*.jnilib") |
240 | - FILE(GLOB sikuli_script_jnilibs "${BASE_DIR}/../sikuli-script/target/lib/*.jnilib") |
241 | - LIST(APPEND jnilibs ${sikuli_script_jnilibs}) |
242 | - |
243 | - find_dep_libs("${jnilibs}" deplibs) |
244 | - find_dep_libs("${deplibs}" deplibs) |
245 | - #MESSAGE("Dep: ${deplibs}") |
246 | - |
247 | -ENDIF(APPLE) |
248 | - |
249 | -SET(RELEASE_FILE "Sikuli-${SIKULI_VERSION}-${OS}") |
250 | - |
251 | -## Packaging App |
252 | -add_custom_target( ${APP_FILE} |
253 | - COMMENT "Generate ${BINARY_DIR}/${APP_FILE}" |
254 | -) |
255 | - |
256 | -add_dependencies( ${APP_FILE} ${JAR_FILE} ) |
257 | - |
258 | -IF(LINUX) |
259 | - EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE SYSTEM_ARCH) |
260 | - SET(RELEASE_FILE "${RELEASE_FILE}-${SYSTEM_ARCH}") |
261 | - if(SYSTEM_ARCH MATCHES "x86_64") |
262 | - SET(LIB_GRABKEY "${COMMON_LIB_DIR}/jxgrabkey/lib/libJXGrabKey-64.so") |
263 | - else() |
264 | - SET(LIB_GRABKEY "${COMMON_LIB_DIR}/jxgrabkey/lib/libJXGrabKey-32.so") |
265 | - endif() |
266 | - |
267 | - add_custom_target( ${APP_FILE}.framework |
268 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${FRAMEWORKS_IN_APP_DIR} |
269 | - COMMAND cp ${jnilibs} ${FRAMEWORKS_IN_APP_DIR} |
270 | - COMMENT "Packaging Frameworks in App" |
271 | - ) |
272 | - add_dependencies( ${APP_FILE} ${APP_FILE}.framework ) |
273 | - |
274 | -ENDIF(LINUX) |
275 | - |
276 | -IF(WIN32) |
277 | - SET(APP_FILES Sikuli-IDE-w.bat Sikuli-IDE.bat Sikuli-IDE.exe ide-icon.ico) |
278 | - SET(WIN32_LIBS ${COMMON_LIB_DIR}/win32) |
279 | - SET(OPENCV_LIBS cv210 cvaux210 cxcore210 highgui210 ml210) |
280 | - |
281 | - SET(LIB_GRABKEY "${COMMON_LIB_DIR}/jintellitype-1.3.6/JIntellitype.dll") |
282 | - add_custom_target( ${JAR_FILE}.framework |
283 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${JAR_LIB_DIR} |
284 | - #COMMAND ${CMAKE_COMMAND} -E copy ${LIB_GRABKEY} ${JAR_LIB_DIR}/ |
285 | - COMMENT "Packaging Frameworks in Jar" |
286 | - ) |
287 | - add_dependencies( ${JAR_FILE} ${JAR_FILE}.framework ) |
288 | - |
289 | - add_custom_target( ${APP_FILE}.framework |
290 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${FRAMEWORKS_IN_APP_DIR} |
291 | - COMMAND ${CMAKE_COMMAND} -E copy_directory ${WIN32_LIBS} ${FRAMEWORKS_IN_APP_DIR} |
292 | - COMMENT "Packaging Frameworks in App" |
293 | - ) |
294 | - add_dependencies( ${APP_FILE} ${APP_FILE}.framework ) |
295 | - |
296 | - #libs |
297 | - |
298 | - install(FILES ${jnilibs} |
299 | - DESTINATION ${FRAMEWORKS_IN_APP_DIR}) |
300 | - FOREACH(F ${OPENCV_LIBS}) |
301 | - install(FILES ${OpenCV_DIR}/bin/${F}.dll |
302 | - DESTINATION ${FRAMEWORKS_IN_APP_DIR}) |
303 | - ENDFOREACH() |
304 | - |
305 | - FOREACH(F ${APP_FILES}) |
306 | - install(FILES ${BINARY_APP_DIR}/${F} |
307 | - DESTINATION ${JAR_IN_APP_DIR}) |
308 | - |
309 | - ENDFOREACH() |
310 | -ENDIF(WIN32) |
311 | - |
312 | -IF(APPLE) |
313 | - add_custom_target( ${APP_FILE}.framework |
314 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${FRAMEWORKS_IN_APP_DIR} |
315 | - COMMAND cp -f ${jnilibs} ${FRAMEWORKS_IN_APP_DIR} |
316 | - COMMAND cp -f ${deplibs} ${FRAMEWORKS_IN_APP_DIR} |
317 | - COMMAND ${CMAKE_COMMAND} -E chdir ${FRAMEWORKS_IN_APP_DIR} ./change-lib-path.sh |
318 | - COMMENT "Packaging Frameworks" |
319 | - ) |
320 | - |
321 | - add_custom_target( ${APP_FILE}.update_ver |
322 | - COMMAND defaults write ${BINARY_APP_DIR}/${APP_FILE}/Contents/Info CFBundleVersion `echo ${SIKULI_VERSION} | awk '{print $$1}'` |
323 | - COMMAND plutil -convert xml1 ${BINARY_APP_DIR}/${APP_FILE}/Contents/Info.plist |
324 | - ) |
325 | - |
326 | - add_dependencies( ${APP_FILE} ${APP_FILE}.framework ${APP_FILE}.update_ver) |
327 | - |
328 | -ENDIF(APPLE) |
329 | - |
330 | -install(DIRECTORY ${BINARY_APP_DIR}/${APP_FILE} |
331 | - USE_SOURCE_PERMISSIONS |
332 | - DESTINATION . |
333 | -) |
334 | - |
335 | - |
336 | -add_custom_target( app ALL |
337 | -) |
338 | - |
339 | - |
340 | -FOREACH(JAR ${INCLUDE_JARS}) |
341 | - get_filename_component(JAR_FILENAME ${JAR} NAME) |
342 | - get_filename_component(target ${JAR} NAME_WE) |
343 | - set(target "include_${target}") |
344 | - add_custom_target( ${target} |
345 | - COMMAND ${CMAKE_COMMAND} -E copy ${JAR} ${JAR_IN_APP_DIR}/${JAR_FILENAME} |
346 | - |
347 | - COMMENT "Copying ${JAR_FILENAME}" |
348 | - ) |
349 | - add_dependencies( ${APP_FILE} ${target} ) |
350 | -ENDFOREACH(JAR ${INCLUDE_JARS}) |
351 | - |
352 | - |
353 | -add_dependencies( app ${APP_FILE}) |
354 | - |
355 | -## Language files |
356 | - |
357 | -add_custom_target( update-po |
358 | - COMMAND prop2po ${RESOURCE_DIR}/i18n/IDE_en_US.properties > ${RESOURCE_DIR}/i18n/IDE/IDE.pot |
359 | - |
360 | - COMMENT "Update the IDE.pot file" |
361 | -) |
362 | - |
363 | -add_custom_target( update-prop |
364 | - COMMAND ${BASE_DIR}/../utils/update-prop.sh ${RESOURCE_DIR} |
365 | - COMMENT "Update the IDE language properties." |
366 | -) |
367 | - |
368 | - |
369 | -## Packaging |
370 | - |
371 | -if(APPLE) |
372 | - SET(CPACK_GENERATOR DragNDrop ) |
373 | - # SET(CPACK_GENERATOR ZIP ) |
374 | -else(APPLE) |
375 | - SET(CPACK_GENERATOR |
376 | - ZIP |
377 | - ) |
378 | -endif(APPLE) |
379 | - |
380 | -SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sikuli ${SIKULI_VERSION}") |
381 | -SET(CPACK_PACKAGE_VENDOR "Sikuli Development Team") |
382 | -SET(CPACK_PACKAGE_DESCRIPTION_FILE "${BASE_DIR}/../readme.txt") |
383 | -SET(CPACK_RESOURCE_FILE_LICENSE "${BASE_DIR}/../copyright.txt") |
384 | -SET(CPACK_PACKAGE_FILE_NAME ${RELEASE_FILE}) |
385 | - |
386 | -INCLUDE(CPack) |
387 | - |
388 | -install(FILES |
389 | - ${CPACK_PACKAGE_DESCRIPTION_FILE} |
390 | - ${CPACK_RESOURCE_FILE_LICENSE} |
391 | - DESTINATION . |
392 | -) |
393 | - |
394 | -# type "make package" to generate release packages |
395 | - |
396 | - |
397 | -## tests |
398 | - |
399 | -SET(MAIN_TEST_SUITE ${PACKAGE}.SikuliIDETestSuite) |
400 | - |
401 | -add_custom_target( java-test.test-res |
402 | - COMMAND ${CMAKE_COMMAND} -E copy_directory ${BASE_DIR}/${TEST_RESOURCE_DIR} ${CMAKE_BINARY_DIR}/${TEST_RESOURCE_DIR} |
403 | - COMMENT "Copy test resource" |
404 | -) |
405 | - |
406 | -add_custom_target( java-test |
407 | - # COMMAND ${JAVA_RUNTIME} -cp ${TEST_CLASS_DIR}${SEP}${BINARY_DIR}/${JAR_FILE}${SEP}${JUNIT_JAR} junit.textui.TestRunner ${MAIN_TEST_SUITE} |
408 | - COMMAND ant -f ${JAVA_TEST_FOR_HUDSON_XML} |
409 | - COMMENT "Run Java unit tests" |
410 | -) |
411 | - |
412 | -add_dependencies( java-test |
413 | - ${JAR_FILE} |
414 | - ${PROJECT_NAME}.test.classes |
415 | - java-test.test-res |
416 | -) |
417 | - |
418 | -add_custom_target( all-test |
419 | -) |
420 | - |
421 | -add_dependencies( all-test |
422 | - java-test |
423 | -) |
424 | - |
425 | -## Dependencies |
426 | - |
427 | -add_dependencies( ${JAR_FILE}.prepare |
428 | - ${JAR_FILE}.resources |
429 | - ${JAR_FILE}.classes-in-jar |
430 | - # ${JAR_FILE}.libs-in-jar |
431 | -) |
432 | - |
433 | -add_dependencies( ${JAR_FILE} ${JAR_FILE}.prepare ) |
434 | -add_dependencies( run-user ${JAR_FILE}) |
435 | -add_dependencies( run ${JAR_FILE}) |
436 | -add_dependencies( app ${APP_FILE}) |
437 | - |
438 | - |
439 | -ADD_SUBDIRECTORY( ${JAVA_SRC_DIR} ) |
440 | -#ADD_SUBDIRECTORY( ${NATIVE_SRC_DIR} ) |
441 | -ADD_SUBDIRECTORY( ${JAVA_TEST_DIR} ) |
442 | - |
443 | - |
444 | - |
445 | -SET(SIKULI_VERSION CACHE INTERNAL "" FORCE) |
446 | - |
447 | |
448 | === removed directory '.pc/gcc-4.7.patch' |
449 | === removed directory '.pc/gcc-4.7.patch/sikuli-script' |
450 | === removed directory '.pc/gcc-4.7.patch/sikuli-script/src' |
451 | === removed directory '.pc/gcc-4.7.patch/sikuli-script/src/main' |
452 | === removed directory '.pc/gcc-4.7.patch/sikuli-script/src/main/native' |
453 | === removed file '.pc/gcc-4.7.patch/sikuli-script/src/main/native/sikuli-debug.h' |
454 | --- .pc/gcc-4.7.patch/sikuli-script/src/main/native/sikuli-debug.h 2012-05-11 23:51:05 +0000 |
455 | +++ .pc/gcc-4.7.patch/sikuli-script/src/main/native/sikuli-debug.h 1970-01-01 00:00:00 +0000 |
456 | @@ -1,52 +0,0 @@ |
457 | -/* |
458 | - * Copyright 2010-2011, Sikuli.org |
459 | - * Released under the MIT License. |
460 | - * |
461 | - */ |
462 | -#ifndef _SIKULU_DEBUG_H |
463 | -#define _SIKULI_DEBUG_H |
464 | - |
465 | - |
466 | -#include <streambuf> |
467 | -#include <ostream> |
468 | - |
469 | -namespace sikuli{ |
470 | - enum DebugCategories { |
471 | - OCR, FINDER |
472 | - }; |
473 | - void setDebug(DebugCategories cat, int level); |
474 | - |
475 | - extern int OCR_DEBUG_LEVEL; |
476 | - extern int FINDER_DEBUG_LEVEL; |
477 | - |
478 | - template <class cT, class traits = std::char_traits<cT> > |
479 | - class basic_nullbuf: public std::basic_streambuf<cT, traits> { |
480 | - typename traits::int_type overflow(typename traits::int_type c) |
481 | - { |
482 | - return traits::not_eof(c); // indicate success |
483 | - } |
484 | - }; |
485 | - |
486 | - template <class cT, class traits = std::char_traits<cT> > |
487 | - class basic_onullstream: public std::basic_ostream<cT, traits> { |
488 | - public: |
489 | - basic_onullstream(): |
490 | - std::basic_ios<cT, traits>(&m_sbuf), |
491 | - std::basic_ostream<cT, traits>(&m_sbuf) |
492 | - { |
493 | - init(&m_sbuf); |
494 | - } |
495 | - |
496 | - private: |
497 | - basic_nullbuf<cT, traits> m_sbuf; |
498 | - }; |
499 | - |
500 | - typedef basic_onullstream<char> onullstream; |
501 | - typedef basic_onullstream<wchar_t> wonullstream; |
502 | - |
503 | - std::ostream& dout(const char* name=""); |
504 | - std::ostream& dhead(const char* name); |
505 | - |
506 | -} |
507 | - |
508 | -#endif |
509 | |
510 | === removed directory '.pc/install-extension.patch' |
511 | === removed directory '.pc/install-extension.patch/sikuli-script' |
512 | === removed directory '.pc/install-extension.patch/sikuli-script/src' |
513 | === removed directory '.pc/install-extension.patch/sikuli-script/src/main' |
514 | === removed directory '.pc/install-extension.patch/sikuli-script/src/main/java' |
515 | === removed directory '.pc/install-extension.patch/sikuli-script/src/main/java/org' |
516 | === removed directory '.pc/install-extension.patch/sikuli-script/src/main/java/org/sikuli' |
517 | === removed directory '.pc/install-extension.patch/sikuli-script/src/main/java/org/sikuli/script' |
518 | === removed file '.pc/install-extension.patch/sikuli-script/src/main/java/org/sikuli/script/ExtensionManager.java' |
519 | --- .pc/install-extension.patch/sikuli-script/src/main/java/org/sikuli/script/ExtensionManager.java 2011-10-04 00:57:09 +0000 |
520 | +++ .pc/install-extension.patch/sikuli-script/src/main/java/org/sikuli/script/ExtensionManager.java 1970-01-01 00:00:00 +0000 |
521 | @@ -1,175 +0,0 @@ |
522 | -/* |
523 | - * Copyright 2010-2011, Sikuli.org |
524 | - * Released under the MIT License. |
525 | - * |
526 | - */ |
527 | -package org.sikuli.script; |
528 | - |
529 | -import java.io.*; |
530 | -import java.net.URL; |
531 | -import java.util.ArrayList; |
532 | - |
533 | -class Extension implements Serializable{ |
534 | - public String name; |
535 | - public String url; |
536 | - public String version; |
537 | - |
538 | - public Extension(String name_, String url_, String version_){ |
539 | - name = name_; |
540 | - url = url_; |
541 | - version = version_; |
542 | - } |
543 | -} |
544 | - |
545 | -public class ExtensionManager { |
546 | - protected final static String EXT_LIST_FILE = ".ext-list"; |
547 | - protected static ExtensionManager _instance = null; |
548 | - protected File _extListFile; |
549 | - protected ArrayList<Extension> _extensions; |
550 | - |
551 | - public static ExtensionManager getInstance(){ |
552 | - if(_instance == null) |
553 | - _instance = new ExtensionManager(); |
554 | - return _instance; |
555 | - } |
556 | - |
557 | - protected void readExtList() { |
558 | - try{ |
559 | - FileInputStream fis = new FileInputStream(_extListFile); |
560 | - ObjectInputStream in = new ObjectInputStream(fis); |
561 | - _extensions = (ArrayList<Extension>)in.readObject(); |
562 | - in.close(); |
563 | - } |
564 | - catch(Exception e){ |
565 | - _extensions = new ArrayList<Extension>(); |
566 | - } |
567 | - } |
568 | - |
569 | - protected void updateExtList() throws IOException, ClassNotFoundException{ |
570 | - FileOutputStream fos = new FileOutputStream(_extListFile); |
571 | - ObjectOutputStream out = new ObjectOutputStream(fos); |
572 | - out.writeObject(_extensions); |
573 | - out.close(); |
574 | - } |
575 | - |
576 | - protected ExtensionManager(){ |
577 | - _extListFile = new File(getUserExtPath(),EXT_LIST_FILE); |
578 | - readExtList(); |
579 | - } |
580 | - |
581 | - |
582 | - protected Extension find(String name){ |
583 | - for(Extension e : _extensions){ |
584 | - if(e.name.equals(name)) |
585 | - return e; |
586 | - } |
587 | - return null; |
588 | - } |
589 | - |
590 | - protected void addExtension(String name, String url, String version){ |
591 | - |
592 | - // remove the previously installed extension of the same name |
593 | - Extension old_ext = find(name); |
594 | - if (old_ext != null) |
595 | - _extensions.remove(old_ext); |
596 | - |
597 | - Extension ext = new Extension(name, url, version); |
598 | - _extensions.add(ext); |
599 | - |
600 | - try{ |
601 | - updateExtList(); |
602 | - } |
603 | - catch(Exception e){ |
604 | - e.printStackTrace(); |
605 | - } |
606 | - } |
607 | - |
608 | - |
609 | - public String getVersion(String name){ |
610 | - Extension e = find(name); |
611 | - if (e != null){ |
612 | - return e.version; |
613 | - }else{ |
614 | - return null; |
615 | - } |
616 | - } |
617 | - |
618 | - public boolean isOutOfDate(String name, String version){ |
619 | - Extension e = find(name); |
620 | - if (e == null){ |
621 | - return false; |
622 | - }else{ |
623 | - String s1 = normalisedVersion(e.version); // installed version |
624 | - String s2 = normalisedVersion(version); // version number to check |
625 | - int cmp = s1.compareTo(s2); |
626 | - return cmp < 0; |
627 | - } |
628 | - } |
629 | - |
630 | - public boolean isInstalled(String name){ |
631 | - Extension e = find(name); |
632 | - return e != null; |
633 | - } |
634 | - |
635 | - private String getExtName(String nameWithVer){ |
636 | - int verSep = nameWithVer.lastIndexOf("-"); |
637 | - if(verSep>=0){ |
638 | - return nameWithVer.substring(0, verSep) + ".jar"; |
639 | - } |
640 | - return nameWithVer; |
641 | - } |
642 | - |
643 | - /** |
644 | - * install a Sikuli extension (.JAR) |
645 | - */ |
646 | - public boolean install(String name, String url_, String version_){ |
647 | - String extPath = getUserExtPath(); |
648 | - String tmpdir = System.getProperty("java.io.tmpdir"); |
649 | - try{ |
650 | - URL url = new URL(url_); |
651 | - File localFile = new File(Util.downloadURL(url, tmpdir)); |
652 | - String extName = getExtName(localFile.getName()); |
653 | - File targetFile = new File(extPath, extName); |
654 | - if(targetFile.exists()) |
655 | - targetFile.delete(); |
656 | - if( !localFile.renameTo(targetFile) ){ |
657 | - Debug.error("Failed to install " + localFile.getName() + " to " + targetFile.getAbsolutePath()); |
658 | - return false; |
659 | - } |
660 | - addExtension(name, url_, version_); |
661 | - } |
662 | - catch(IOException e){ |
663 | - Debug.error("Failed to download " + url_); |
664 | - e.printStackTrace(); |
665 | - return false; |
666 | - } |
667 | - return true; |
668 | - } |
669 | - |
670 | - /** |
671 | - * returns the absolute path to the user's extension path |
672 | - */ |
673 | - public String getUserExtPath(){ |
674 | - String ret = Env.getSikuliDataPath() + File.separator + "extensions"; |
675 | - File f = new File(ret); |
676 | - if(!f.exists()) |
677 | - f.mkdirs(); |
678 | - return ret; |
679 | - } |
680 | - |
681 | - |
682 | - |
683 | - public static String normalisedVersion(String version) { |
684 | - return normalisedVersion(version, ".", 4); |
685 | - } |
686 | - |
687 | - public static String normalisedVersion(String version, String sep, int maxWidth) { |
688 | - String[] split = java.util.regex.Pattern.compile(sep, java.util.regex.Pattern.LITERAL).split(version); |
689 | - StringBuilder sb = new StringBuilder(); |
690 | - for (String s : split) { |
691 | - sb.append(String.format("%" + maxWidth + 's', s)); |
692 | - } |
693 | - return sb.toString(); |
694 | - } |
695 | - |
696 | -} |
697 | |
698 | === removed directory '.pc/jgoodies-1.6-compat.patch' |
699 | === removed directory '.pc/jgoodies-1.6-compat.patch/sikuli-ide' |
700 | === removed file '.pc/jgoodies-1.6-compat.patch/sikuli-ide/CMakeLists.txt' |
701 | --- .pc/jgoodies-1.6-compat.patch/sikuli-ide/CMakeLists.txt 2012-12-07 22:13:08 +0000 |
702 | +++ .pc/jgoodies-1.6-compat.patch/sikuli-ide/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
703 | @@ -1,405 +0,0 @@ |
704 | -# Copyright 2010-2011, Sikuli.org |
705 | -# Released under the MIT License. |
706 | -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) |
707 | -PROJECT (sikuli-ide Java) |
708 | - |
709 | -SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules") |
710 | -INCLUDE(${CMAKE_MODULE_PATH}/common.cmake) |
711 | -INCLUDE(${CMAKE_MODULE_PATH}/detect_osx_ver.cmake) |
712 | -INCLUDE(${CMAKE_MODULE_PATH}/find_dep_libs.cmake) |
713 | - |
714 | - |
715 | -ENABLE_TESTING() |
716 | - |
717 | -SET(CMAKE_VERBOSE_MAKEFILE 0) |
718 | - |
719 | -FIND_PACKAGE(Java 1.6 REQUIRED) |
720 | -SET( NON_NATIVE_TARGET TRUE) |
721 | - |
722 | -IF(UNIX) |
723 | - SET(SEP ":") |
724 | -ELSE() |
725 | - SET(SEP ";") |
726 | -ENDIF() |
727 | - |
728 | - |
729 | -SET(BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") |
730 | -SET(JAVA_SRC_DIR "${BASE_DIR}/src/main/java") |
731 | -SET(NATIVE_SRC_DIR "${BASE_DIR}/src/main/native") |
732 | -SET(COMMON_LIB_DIR "${BASE_DIR}/../lib") |
733 | -SET(INCLUDE_LIB_DIR "${BASE_DIR}/lib") |
734 | -SET(BINARY_DIR "${BASE_DIR}/target") |
735 | -SET(BINARY_CLASS_DIR "${BINARY_DIR}/classes") |
736 | -SET(BINARY_LIB_DIR "${BINARY_DIR}/lib") |
737 | -SET(JAR_DIR "${BINARY_DIR}/jar") |
738 | -SET(RESOURCE_DIR "${BASE_DIR}/resources") |
739 | -SET(RELEASE_DIR "${BASE_DIR}/../release") |
740 | - |
741 | -SET(JAVA_TEST_DIR "${BASE_DIR}/src/test/java") |
742 | -SET(TEST_RESOURCE_DIR "test-res") |
743 | -SET(JAVA_TEST_FOR_HUDSON_XML "../hudson-test.xml") |
744 | -SET(TEST_CLASS_DIR "${CMAKE_BINARY_DIR}/test") |
745 | - |
746 | -SET(SIKULI_SCRIPT_JAR "${COMMON_LIB_DIR}/sikuli-script.jar") |
747 | -SET(JUNIT_JAR "/usr/share/java/junit.jar") |
748 | -SET(SWING_LAYOUT_JAR "/usr/share/java/swing-layout.jar") |
749 | -SET(COMMONS_CLI_JAR "/usr/share/java/commons-cli.jar") |
750 | -SET(JSON_SIMPLE_JAR "/usr/share/java/json_simple.jar") |
751 | -SET(SWINGX_JAR "/usr/share/java/swingx-core.jar") |
752 | -SET(MAC_WIDGETS_JAR "/usr/share/java/mac_widgets.jar") |
753 | -SET(FORMS_JAR "/usr/share/java/forms.jar") |
754 | - |
755 | - |
756 | -FILE(MAKE_DIRECTORY ${BINARY_DIR}) |
757 | -FILE(MAKE_DIRECTORY ${BINARY_CLASS_DIR}) |
758 | -FILE(MAKE_DIRECTORY ${JAR_DIR}) |
759 | -FILE(MAKE_DIRECTORY ${TEST_CLASS_DIR}) |
760 | - |
761 | -## Sikuli IDE |
762 | - |
763 | -SET(MAIN_CLASS org.sikuli.ide.SikuliIDE) |
764 | -SET(RUN_USER_ARGS -Dsikuli.console=true -Dfile.encoding=UTF-8 |
765 | - -Dsikuli.testing=yes |
766 | - -Xms64m -Xmx512m |
767 | - CACHE STRING |
768 | - "The arguments for running Sikuli IDE with 'make run-user'" |
769 | -) |
770 | -SET(RUN_ARGS -Dsikuli.console=false -Dsikuli.Debug=3 -Dfile.encoding=UTF-8 |
771 | - -Dsikuli.testing=yes |
772 | - -Xms64m -Xmx512m |
773 | - #-Duser.language=zh -Duser.region=TW |
774 | - CACHE STRING |
775 | - "The arguments for running Sikuli IDE with 'make run'" |
776 | -) |
777 | -IF(APPLE) |
778 | - LIST(APPEND RUN_ARGS -Xdock:name='Sikuli IDE') |
779 | -ENDIF() |
780 | - |
781 | -#SET(ARGS -s -r ../sample-scripts/mod1.sikuli --args a1 a2) # example args |
782 | -SET(ARGS "") |
783 | - |
784 | -SET(CLASSPATH |
785 | - ${SIKULI_SCRIPT_JAR}${SEP}${JUNIT_JAR}${SEP}${SWING_LAYOUT_JAR}${SEP}${COMMONS_CLI_JAR}${SEP}${JSON_SIMPLE_JAR}${SEP}${SWINGX_JAR}${SEP}${MAC_WIDGETS_JAR}${SEP}${FORMS_JAR}${SEP}/usr/share/java/jython.jar |
786 | -) |
787 | - |
788 | -SET(JAR_FILE sikuli-ide.jar) |
789 | -SET(RESOURCES icons META-INF scripts i18n) |
790 | - |
791 | -IF(LINUX) |
792 | - SET(MANIFEST ${RESOURCE_DIR}/META-INF/MANIFEST-linux.MF) |
793 | - #SET(CLASSPATH ${CLASSPATH}${SEP}${JXGRABKEY_JAR}) |
794 | -ELSEIF(WIN32) |
795 | - SET(MANIFEST ${RESOURCE_DIR}/META-INF/MANIFEST-win32.MF) |
796 | - #SET(CLASSPATH ${CLASSPATH}${SEP}${JINTELLITYPE_JAR}) |
797 | -ELSE() |
798 | - SET(MANIFEST ${RESOURCE_DIR}/META-INF/MANIFEST.MF) |
799 | -ENDIF() |
800 | - |
801 | - |
802 | -add_custom_target( ${JAR_FILE} |
803 | - COMMAND ${JAVA_ARCHIVE} cfm ${BINARY_DIR}/${JAR_FILE} |
804 | - ${MANIFEST} -C ${JAR_DIR} * |
805 | - COMMAND ${CMAKE_COMMAND} -E copy ${BINARY_DIR}/${JAR_FILE} ${COMMON_LIB_DIR}/${JAR_FILE} |
806 | - COMMENT "Packaging ${JAR_FILE}" |
807 | - WORKING_DIRECTORY ${JAR_DIR} |
808 | -) |
809 | - |
810 | -add_custom_target( ${JAR_FILE}.resources |
811 | - COMMAND ${CMAKE_COMMAND} -E copy_directory ${RESOURCE_DIR} ${JAR_DIR} |
812 | - COMMENT "Copying IDE resources" |
813 | -) |
814 | - |
815 | -add_custom_target( ${JAR_FILE}.prepare |
816 | - COMMENT "Preparing ${JAR_FILE}" |
817 | -) |
818 | - |
819 | -add_custom_target( run-user |
820 | - COMMAND ${JAVA_RUNTIME} ${RUN_USER_ARGS} |
821 | - -classpath "${CLASSPATH}${SEP}${JAR_DIR}" |
822 | - ${MAIN_CLASS} ${ARGS} |
823 | -) |
824 | - |
825 | -add_custom_target( run |
826 | - COMMAND ${JAVA_RUNTIME} ${RUN_ARGS} |
827 | - -classpath "${CLASSPATH}${SEP}${JAR_DIR}" |
828 | - ${MAIN_CLASS} ${ARGS} |
829 | -) |
830 | - |
831 | -if(NOT DEFINED SIKULI_VERSION OR SIKULI_VERSION STREQUAL "") |
832 | - file(READ ${BASE_DIR}/latest-ver SIKULI_VERSION) |
833 | - STRING(STRIP ${SIKULI_VERSION} SIKULI_VERSION) |
834 | -ENDIF() |
835 | -message("Sikuli Version ${SIKULI_VERSION}") |
836 | - |
837 | -SET(JYTHON_CLASS org.python.util.jython) |
838 | -add_custom_target( update-version |
839 | - COMMAND ${JAVA_RUNTIME} -cp "${CLASSPATH}" ${JYTHON_CLASS} ${BASE_DIR}/../utils/update-version.py ${JAVA_SRC_DIR}/org/sikuli/ide/IDESettings.java "${SIKULI_VERSION}" |
840 | - COMMENT "Update version number in Sikuli-IDE" |
841 | -) |
842 | - |
843 | -SET(INCLUDE_JARS ${SIKULI_SCRIPT_JAR} ${JUNIT_JAR} |
844 | - ${SWING_LAYOUT_JAR} ${COMMONS_CLI_JAR} |
845 | - ${BINARY_DIR}/${JAR_FILE} ${JSON_SIMPLE_JAR} |
846 | - ${SWINGX_JAR} ${MAC_WIDGETS_JAR} ${FORMS_JAR} |
847 | -) |
848 | - |
849 | -## Windows Package |
850 | - |
851 | -IF(WIN32) |
852 | - SET(OS "win32") |
853 | - SET(APP_FILE "Sikuli-IDE") |
854 | - SET(BINARY_APP_DIR "${BINARY_DIR}/${OS}") |
855 | - SET(JAR_IN_APP_DIR ${BINARY_APP_DIR}/${APP_FILE}) |
856 | - SET(FRAMEWORKS_IN_APP_DIR ${JAR_IN_APP_DIR}/libs) |
857 | - SET(JAR_LIB_DIR ${JAR_DIR}/META-INF/lib) |
858 | - |
859 | - #LIST(APPEND INCLUDE_JARS ${JINTELLITYPE_JAR}) |
860 | - FILE(GLOB sikuli_script_jnilibs "${BASE_DIR}/../sikuli-script/target/lib/*.dll") |
861 | - SET(jnilibs ${sikuli_script_jnilibs}) |
862 | -ENDIF() |
863 | - |
864 | -## Linux Package |
865 | - |
866 | -IF(LINUX) |
867 | - SET(OS "linux") |
868 | - SET(APP_FILE "Sikuli-IDE") |
869 | - SET(BINARY_APP_DIR "${BINARY_DIR}/${OS}") |
870 | - SET(JAR_IN_APP_DIR ${BINARY_APP_DIR}/${APP_FILE}) |
871 | - SET(FRAMEWORKS_IN_APP_DIR ${JAR_IN_APP_DIR}/libs) |
872 | - SET(JAR_LIB_DIR ${JAR_DIR}/META-INF/lib) |
873 | - |
874 | - #LIST(APPEND INCLUDE_JARS ${JXGRABKEY_JAR}) |
875 | - SET(jnilibs "") |
876 | - FILE(GLOB sikuli_script_jnilibs "${BASE_DIR}/../sikuli-script/target/lib/*.so") |
877 | - LIST(APPEND jnilibs ${sikuli_script_jnilibs}) |
878 | -ENDIF(LINUX) |
879 | - |
880 | -## Sikuli-IDE.App for Mac OS X |
881 | - |
882 | -IF(APPLE) |
883 | - IF(APPLE_SNOW_LEOPARD) |
884 | - SET(OSX_VER "osx-10.6") |
885 | - ELSEIF(APPLE_LEOPARD) |
886 | - SET(OSX_VER "osx-10.5") |
887 | - ENDIF() |
888 | - SET(OS ${OSX_VER}) |
889 | - |
890 | - SET(APP_FILE "Sikuli-IDE.app") |
891 | - SET(BINARY_APP_DIR "${BINARY_DIR}/${OS}") |
892 | - SET(JAR_IN_APP_DIR ${BINARY_APP_DIR}/${APP_FILE}/Contents/Resources/Java) |
893 | - SET(FRAMEWORKS_IN_APP_DIR ${BINARY_APP_DIR}/${APP_FILE}/Contents/Frameworks) |
894 | - |
895 | - FIND_PACKAGE(OpenCV REQUIRED) |
896 | - #message("opencv lib: ${OpenCV_LIB_DIR}") |
897 | - LIST(APPEND CMAKE_LIBRARY_PATH ${OpenCV_LIB_DIR}) |
898 | - |
899 | - FILE(GLOB jnilibs "${BINARY_LIB_DIR}/*.jnilib") |
900 | - FILE(GLOB sikuli_script_jnilibs "${BASE_DIR}/../sikuli-script/target/lib/*.jnilib") |
901 | - LIST(APPEND jnilibs ${sikuli_script_jnilibs}) |
902 | - |
903 | - find_dep_libs("${jnilibs}" deplibs) |
904 | - find_dep_libs("${deplibs}" deplibs) |
905 | - #MESSAGE("Dep: ${deplibs}") |
906 | - |
907 | -ENDIF(APPLE) |
908 | - |
909 | -SET(RELEASE_FILE "Sikuli-${SIKULI_VERSION}-${OS}") |
910 | - |
911 | -## Packaging App |
912 | -add_custom_target( ${APP_FILE} |
913 | - COMMENT "Generate ${BINARY_DIR}/${APP_FILE}" |
914 | -) |
915 | - |
916 | -add_dependencies( ${APP_FILE} ${JAR_FILE} ) |
917 | - |
918 | -IF(LINUX) |
919 | - EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE SYSTEM_ARCH) |
920 | - SET(RELEASE_FILE "${RELEASE_FILE}-${SYSTEM_ARCH}") |
921 | - if(SYSTEM_ARCH MATCHES "x86_64") |
922 | - SET(LIB_GRABKEY "${COMMON_LIB_DIR}/jxgrabkey/lib/libJXGrabKey-64.so") |
923 | - else() |
924 | - SET(LIB_GRABKEY "${COMMON_LIB_DIR}/jxgrabkey/lib/libJXGrabKey-32.so") |
925 | - endif() |
926 | - |
927 | - add_custom_target( ${APP_FILE}.framework |
928 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${FRAMEWORKS_IN_APP_DIR} |
929 | - COMMAND cp ${jnilibs} ${FRAMEWORKS_IN_APP_DIR} |
930 | - COMMENT "Packaging Frameworks in App" |
931 | - ) |
932 | - add_dependencies( ${APP_FILE} ${APP_FILE}.framework ) |
933 | - |
934 | -ENDIF(LINUX) |
935 | - |
936 | -IF(WIN32) |
937 | - SET(APP_FILES Sikuli-IDE-w.bat Sikuli-IDE.bat Sikuli-IDE.exe ide-icon.ico) |
938 | - SET(WIN32_LIBS ${COMMON_LIB_DIR}/win32) |
939 | - SET(OPENCV_LIBS cv210 cvaux210 cxcore210 highgui210 ml210) |
940 | - |
941 | - SET(LIB_GRABKEY "${COMMON_LIB_DIR}/jintellitype-1.3.6/JIntellitype.dll") |
942 | - add_custom_target( ${JAR_FILE}.framework |
943 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${JAR_LIB_DIR} |
944 | - #COMMAND ${CMAKE_COMMAND} -E copy ${LIB_GRABKEY} ${JAR_LIB_DIR}/ |
945 | - COMMENT "Packaging Frameworks in Jar" |
946 | - ) |
947 | - add_dependencies( ${JAR_FILE} ${JAR_FILE}.framework ) |
948 | - |
949 | - add_custom_target( ${APP_FILE}.framework |
950 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${FRAMEWORKS_IN_APP_DIR} |
951 | - COMMAND ${CMAKE_COMMAND} -E copy_directory ${WIN32_LIBS} ${FRAMEWORKS_IN_APP_DIR} |
952 | - COMMENT "Packaging Frameworks in App" |
953 | - ) |
954 | - add_dependencies( ${APP_FILE} ${APP_FILE}.framework ) |
955 | - |
956 | - #libs |
957 | - |
958 | - install(FILES ${jnilibs} |
959 | - DESTINATION ${FRAMEWORKS_IN_APP_DIR}) |
960 | - FOREACH(F ${OPENCV_LIBS}) |
961 | - install(FILES ${OpenCV_DIR}/bin/${F}.dll |
962 | - DESTINATION ${FRAMEWORKS_IN_APP_DIR}) |
963 | - ENDFOREACH() |
964 | - |
965 | - FOREACH(F ${APP_FILES}) |
966 | - install(FILES ${BINARY_APP_DIR}/${F} |
967 | - DESTINATION ${JAR_IN_APP_DIR}) |
968 | - |
969 | - ENDFOREACH() |
970 | -ENDIF(WIN32) |
971 | - |
972 | -IF(APPLE) |
973 | - add_custom_target( ${APP_FILE}.framework |
974 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${FRAMEWORKS_IN_APP_DIR} |
975 | - COMMAND cp -f ${jnilibs} ${FRAMEWORKS_IN_APP_DIR} |
976 | - COMMAND cp -f ${deplibs} ${FRAMEWORKS_IN_APP_DIR} |
977 | - COMMAND ${CMAKE_COMMAND} -E chdir ${FRAMEWORKS_IN_APP_DIR} ./change-lib-path.sh |
978 | - COMMENT "Packaging Frameworks" |
979 | - ) |
980 | - |
981 | - add_custom_target( ${APP_FILE}.update_ver |
982 | - COMMAND defaults write ${BINARY_APP_DIR}/${APP_FILE}/Contents/Info CFBundleVersion `echo ${SIKULI_VERSION} | awk '{print $$1}'` |
983 | - COMMAND plutil -convert xml1 ${BINARY_APP_DIR}/${APP_FILE}/Contents/Info.plist |
984 | - ) |
985 | - |
986 | - add_dependencies( ${APP_FILE} ${APP_FILE}.framework ${APP_FILE}.update_ver) |
987 | - |
988 | -ENDIF(APPLE) |
989 | - |
990 | -install(DIRECTORY ${BINARY_APP_DIR}/${APP_FILE} |
991 | - USE_SOURCE_PERMISSIONS |
992 | - DESTINATION . |
993 | -) |
994 | - |
995 | - |
996 | -add_custom_target( app ALL |
997 | -) |
998 | - |
999 | - |
1000 | -FOREACH(JAR ${INCLUDE_JARS}) |
1001 | - get_filename_component(JAR_FILENAME ${JAR} NAME) |
1002 | - get_filename_component(target ${JAR} NAME_WE) |
1003 | - set(target "include_${target}") |
1004 | - add_custom_target( ${target} |
1005 | - COMMAND ${CMAKE_COMMAND} -E copy ${JAR} ${JAR_IN_APP_DIR}/${JAR_FILENAME} |
1006 | - |
1007 | - COMMENT "Copying ${JAR_FILENAME}" |
1008 | - ) |
1009 | - add_dependencies( ${APP_FILE} ${target} ) |
1010 | -ENDFOREACH(JAR ${INCLUDE_JARS}) |
1011 | - |
1012 | - |
1013 | -get_filename_component(target ${JAR_FILE} NAME_WE) |
1014 | -add_dependencies( include_${target} ${JAR_FILE}) |
1015 | -add_dependencies( app ${APP_FILE}) |
1016 | - |
1017 | -## Language files |
1018 | - |
1019 | -add_custom_target( update-po |
1020 | - COMMAND prop2po ${RESOURCE_DIR}/i18n/IDE_en_US.properties > ${RESOURCE_DIR}/i18n/IDE/IDE.pot |
1021 | - |
1022 | - COMMENT "Update the IDE.pot file" |
1023 | -) |
1024 | - |
1025 | -add_custom_target( update-prop |
1026 | - COMMAND ${BASE_DIR}/../utils/update-prop.sh ${RESOURCE_DIR} |
1027 | - COMMENT "Update the IDE language properties." |
1028 | -) |
1029 | - |
1030 | - |
1031 | -## Packaging |
1032 | - |
1033 | -if(APPLE) |
1034 | - SET(CPACK_GENERATOR DragNDrop ) |
1035 | - # SET(CPACK_GENERATOR ZIP ) |
1036 | -else(APPLE) |
1037 | - SET(CPACK_GENERATOR |
1038 | - ZIP |
1039 | - ) |
1040 | -endif(APPLE) |
1041 | - |
1042 | -SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sikuli ${SIKULI_VERSION}") |
1043 | -SET(CPACK_PACKAGE_VENDOR "Sikuli Development Team") |
1044 | -SET(CPACK_PACKAGE_DESCRIPTION_FILE "${BASE_DIR}/../readme.txt") |
1045 | -SET(CPACK_RESOURCE_FILE_LICENSE "${BASE_DIR}/../copyright.txt") |
1046 | -SET(CPACK_PACKAGE_FILE_NAME ${RELEASE_FILE}) |
1047 | - |
1048 | -INCLUDE(CPack) |
1049 | - |
1050 | -install(FILES |
1051 | - ${CPACK_PACKAGE_DESCRIPTION_FILE} |
1052 | - ${CPACK_RESOURCE_FILE_LICENSE} |
1053 | - DESTINATION . |
1054 | -) |
1055 | - |
1056 | -# type "make package" to generate release packages |
1057 | - |
1058 | - |
1059 | -## tests |
1060 | - |
1061 | -SET(MAIN_TEST_SUITE ${PACKAGE}.SikuliIDETestSuite) |
1062 | - |
1063 | -add_custom_target( java-test.test-res |
1064 | - COMMAND ${CMAKE_COMMAND} -E copy_directory ${BASE_DIR}/${TEST_RESOURCE_DIR} ${CMAKE_BINARY_DIR}/${TEST_RESOURCE_DIR} |
1065 | - COMMENT "Copy test resource" |
1066 | -) |
1067 | - |
1068 | -add_custom_target( java-test |
1069 | - # COMMAND ${JAVA_RUNTIME} -cp ${TEST_CLASS_DIR}${SEP}${BINARY_DIR}/${JAR_FILE}${SEP}${JUNIT_JAR} junit.textui.TestRunner ${MAIN_TEST_SUITE} |
1070 | - COMMAND ant -f ${JAVA_TEST_FOR_HUDSON_XML} |
1071 | - COMMENT "Run Java unit tests" |
1072 | -) |
1073 | - |
1074 | -add_dependencies( java-test |
1075 | - ${JAR_FILE} |
1076 | - ${PROJECT_NAME}.test.classes |
1077 | - java-test.test-res |
1078 | -) |
1079 | - |
1080 | -add_custom_target( all-test |
1081 | -) |
1082 | - |
1083 | -add_dependencies( all-test |
1084 | - java-test |
1085 | -) |
1086 | - |
1087 | -## Dependencies |
1088 | - |
1089 | -add_dependencies( ${JAR_FILE}.prepare |
1090 | - ${JAR_FILE}.resources |
1091 | - ${JAR_FILE}.classes-in-jar |
1092 | - # ${JAR_FILE}.libs-in-jar |
1093 | -) |
1094 | - |
1095 | -add_dependencies( ${JAR_FILE} ${JAR_FILE}.prepare ) |
1096 | -add_dependencies( run-user ${JAR_FILE}) |
1097 | -add_dependencies( run ${JAR_FILE}) |
1098 | -add_dependencies( app ${APP_FILE}) |
1099 | - |
1100 | - |
1101 | -ADD_SUBDIRECTORY( ${JAVA_SRC_DIR} ) |
1102 | -#ADD_SUBDIRECTORY( ${NATIVE_SRC_DIR} ) |
1103 | -ADD_SUBDIRECTORY( ${JAVA_TEST_DIR} ) |
1104 | - |
1105 | - |
1106 | - |
1107 | -SET(SIKULI_VERSION CACHE INTERNAL "" FORCE) |
1108 | - |
1109 | |
1110 | === removed directory '.pc/jgoodies-1.6-compat.patch/sikuli-ide/src' |
1111 | === removed directory '.pc/jgoodies-1.6-compat.patch/sikuli-ide/src/main' |
1112 | === removed directory '.pc/jgoodies-1.6-compat.patch/sikuli-ide/src/main/java' |
1113 | === removed directory '.pc/jgoodies-1.6-compat.patch/sikuli-ide/src/main/java/org' |
1114 | === removed directory '.pc/jgoodies-1.6-compat.patch/sikuli-ide/src/main/java/org/sikuli' |
1115 | === removed directory '.pc/jgoodies-1.6-compat.patch/sikuli-ide/src/main/java/org/sikuli/ide' |
1116 | === removed file '.pc/jgoodies-1.6-compat.patch/sikuli-ide/src/main/java/org/sikuli/ide/PreferencesWin.java' |
1117 | --- .pc/jgoodies-1.6-compat.patch/sikuli-ide/src/main/java/org/sikuli/ide/PreferencesWin.java 2012-12-07 22:13:08 +0000 |
1118 | +++ .pc/jgoodies-1.6-compat.patch/sikuli-ide/src/main/java/org/sikuli/ide/PreferencesWin.java 1970-01-01 00:00:00 +0000 |
1119 | @@ -1,561 +0,0 @@ |
1120 | -/* |
1121 | - * Copyright 2010-2011, Sikuli.org |
1122 | - * Released under the MIT License. |
1123 | - * |
1124 | - */ |
1125 | -package org.sikuli.ide; |
1126 | - |
1127 | -import java.awt.*; |
1128 | -import java.awt.event.*; |
1129 | -import java.util.prefs.*; |
1130 | -import java.util.Arrays; |
1131 | -import java.util.Comparator; |
1132 | -import java.util.Locale; |
1133 | -import java.util.ResourceBundle; |
1134 | -import java.util.MissingResourceException; |
1135 | -import javax.swing.DefaultListCellRenderer; |
1136 | -import javax.swing.JList; |
1137 | -import javax.swing.BoxLayout; |
1138 | -import javax.swing.ButtonGroup; |
1139 | -import javax.swing.JButton; |
1140 | -import javax.swing.JCheckBox; |
1141 | -import javax.swing.JComboBox; |
1142 | -import javax.swing.JFrame; |
1143 | -import javax.swing.JLabel; |
1144 | -import javax.swing.JPanel; |
1145 | -import javax.swing.JRadioButton; |
1146 | -import javax.swing.JSpinner; |
1147 | -import javax.swing.JTabbedPane; |
1148 | -import javax.swing.JTextField; |
1149 | -import javax.swing.SpinnerNumberModel; |
1150 | -import javax.swing.SwingConstants; |
1151 | -import javax.swing.border.EmptyBorder; |
1152 | -import javax.swing.event.ChangeEvent; |
1153 | -import javax.swing.event.ChangeListener; |
1154 | -import com.jgoodies.forms.factories.DefaultComponentFactory; |
1155 | -import org.jdesktop.layout.*; |
1156 | - |
1157 | -import org.sikuli.script.Debug; |
1158 | - |
1159 | -/* |
1160 | - * Created by JFormDesigner on Mon Nov 16 10:13:52 EST 2009 |
1161 | - */ |
1162 | - |
1163 | - |
1164 | -public class PreferencesWin extends JFrame { |
1165 | - UserPreferences pref = UserPreferences.getInstance(); |
1166 | - int _cap_hkey, _cap_mod; |
1167 | - int _old_cap_hkey, _old_cap_mod; |
1168 | - |
1169 | - public PreferencesWin() { |
1170 | - super( SikuliIDE._I("winPreferences") ); |
1171 | - initComponents(); |
1172 | - loadPrefs(); |
1173 | - } |
1174 | - |
1175 | - private void loadPrefs(){ |
1176 | - SikuliIDE ide = SikuliIDE.getInstance(); |
1177 | - double delay = pref.getCaptureDelay(); |
1178 | - _spnDelay.setValue(delay); |
1179 | - _old_cap_hkey = _cap_hkey = pref.getCaptureHotkey(); |
1180 | - _old_cap_mod = _cap_mod = pref.getCaptureHotkeyModifiers(); |
1181 | - setTxtHotkey(_cap_hkey, _cap_mod); |
1182 | - switch(pref.getAutoNamingMethod()){ |
1183 | - case UserPreferences.AUTO_NAMING_TIMESTAMP: |
1184 | - _radTimestamp.setSelected(true); |
1185 | - break; |
1186 | - case UserPreferences.AUTO_NAMING_OCR: |
1187 | - _radOCR.setSelected(true); |
1188 | - break; |
1189 | - case UserPreferences.AUTO_NAMING_OFF: |
1190 | - _radOff.setSelected(true); |
1191 | - break; |
1192 | - default: |
1193 | - Debug.error("Error in reading auto naming method preferences"); |
1194 | - } |
1195 | - _chkAutoUpdate.setSelected(pref.getCheckUpdate()); |
1196 | - |
1197 | - _chkExpandTab.setSelected(pref.getExpandTab()); |
1198 | - _spnTabWidth.setValue(pref.getTabWidth()); |
1199 | - initFontPrefs(); |
1200 | - initLangPrefs(); |
1201 | - } |
1202 | - |
1203 | - private void initLangPrefs(){ |
1204 | - String[] SUPPORT_LOCALES = { |
1205 | - "es", "pt_BR", "ar", "fr", "ru", "bg", "he", "sv", "ca", "ja", "tr", |
1206 | - "da", "ko", "uk", "de", "nl", "zh_CN", "en_US", "pl", "zh_TW" |
1207 | - }; |
1208 | - Locale[] sortedLocales = new Locale[SUPPORT_LOCALES.length]; |
1209 | - UserPreferences pref = UserPreferences.getInstance(); |
1210 | - int count = 0; |
1211 | - for (String locale_code: SUPPORT_LOCALES){ |
1212 | - Locale l; |
1213 | - if( locale_code.indexOf("_")>=0 ){ |
1214 | - String[] lang_country = locale_code.split("_"); |
1215 | - l = new Locale(lang_country[0], lang_country[1]); |
1216 | - } |
1217 | - else |
1218 | - l = new Locale(locale_code); |
1219 | - sortedLocales[count++] = l; |
1220 | - } |
1221 | - Arrays.sort(sortedLocales, new Comparator<Locale>(){ |
1222 | - public int compare(Locale l1, Locale l2) { |
1223 | - return l1.getDisplayLanguage().compareTo(l2.getDisplayLanguage()); |
1224 | - } |
1225 | - }); |
1226 | - |
1227 | - for(Locale l : sortedLocales){ |
1228 | - _cmbLang.addItem(l); |
1229 | - } |
1230 | - _cmbLang.setRenderer(new LocaleListCellRenderer()); |
1231 | - Locale curLocale = pref.getLocale(); |
1232 | - _cmbLang.setSelectedItem(curLocale); |
1233 | - if(!_cmbLang.getSelectedItem().equals(curLocale)){ |
1234 | - if(curLocale.getVariant().length() > 0){ |
1235 | - curLocale = new Locale(curLocale.getLanguage(), curLocale.getCountry()); |
1236 | - _cmbLang.setSelectedItem(curLocale); |
1237 | - } |
1238 | - if(!_cmbLang.getSelectedItem().equals(curLocale)) |
1239 | - _cmbLang.setSelectedItem(new Locale(curLocale.getLanguage())); |
1240 | - } |
1241 | - } |
1242 | - |
1243 | - |
1244 | - private void initFontPrefs(){ |
1245 | - UserPreferences pref = UserPreferences.getInstance(); |
1246 | - String[] fontList = GraphicsEnvironment.getLocalGraphicsEnvironment() |
1247 | - .getAvailableFontFamilyNames(); |
1248 | - for (String font: fontList) |
1249 | - _cmbFontName.addItem(font); |
1250 | - _cmbFontName.setSelectedItem(pref.getFontName()); |
1251 | - _spnFontSize.setValue(pref.getFontSize()); |
1252 | - } |
1253 | - |
1254 | - private void savePrefs(){ |
1255 | - SikuliIDE ide = SikuliIDE.getInstance(); |
1256 | - pref.setCaptureDelay((Double)_spnDelay.getValue()); |
1257 | - pref.setCaptureHotkey(_cap_hkey); |
1258 | - pref.setCaptureHotkeyModifiers(_cap_mod); |
1259 | - pref.setAutoNamingMethod( |
1260 | - _radTimestamp.isSelected()?UserPreferences.AUTO_NAMING_TIMESTAMP: |
1261 | - _radOCR.isSelected()?UserPreferences.AUTO_NAMING_OCR: |
1262 | - UserPreferences.AUTO_NAMING_OFF); |
1263 | - if(_old_cap_hkey != _cap_hkey || _old_cap_mod != _cap_mod){ |
1264 | - ide.removeCaptureHotkey(_old_cap_hkey, _old_cap_mod); |
1265 | - ide.installCaptureHotkey(_cap_hkey, _cap_mod); |
1266 | - } |
1267 | - pref.setCheckUpdate(_chkAutoUpdate.isSelected()); |
1268 | - |
1269 | - pref.setExpandTab(_chkExpandTab.isSelected()); |
1270 | - pref.setTabWidth((Integer)_spnTabWidth.getValue()); |
1271 | - |
1272 | - pref.setFontName( (String)_cmbFontName.getSelectedItem() ); |
1273 | - pref.setFontSize( (Integer)_spnFontSize.getValue() ); |
1274 | - |
1275 | - Locale locale = (Locale)_cmbLang.getSelectedItem(); |
1276 | - pref.setLocale(locale); |
1277 | - I18N.setLocale(locale); |
1278 | - } |
1279 | - |
1280 | - private void setTxtHotkey(int code, int mod){ |
1281 | - _cap_hkey = code; |
1282 | - _cap_mod = mod; |
1283 | - _txtHotkey.setText( Utils.convertKeyToText(code, mod) ); |
1284 | - } |
1285 | - |
1286 | - private void btnOkActionPerformed(ActionEvent e) { |
1287 | - savePrefs(); |
1288 | - this.dispose(); |
1289 | - } |
1290 | - |
1291 | - private void btnCancelActionPerformed(ActionEvent e) { |
1292 | - this.dispose(); |
1293 | - } |
1294 | - |
1295 | - private void txtHotkeyFocusGained(FocusEvent e) { |
1296 | - _txtHotkey.setEditable(true); |
1297 | - } |
1298 | - |
1299 | - private void txtHotkeyKeyPressed(KeyEvent e) { |
1300 | - int code = e.getKeyCode(); |
1301 | - int mod = e.getModifiers(); |
1302 | - Debug.log(7, "" + code + " " + mod); |
1303 | - setTxtHotkey(code, mod); |
1304 | - _txtHotkey.setEditable(false); |
1305 | - } |
1306 | - |
1307 | - private void updateFontPreview(){ |
1308 | - SikuliIDE ide = SikuliIDE.getInstance(); |
1309 | - Font font = new Font((String)_cmbFontName.getSelectedItem(), Font.PLAIN, |
1310 | - (Integer)_spnFontSize.getValue()); |
1311 | - ide.getCurrentCodePane().setFont(font); |
1312 | - } |
1313 | - |
1314 | - private void fontNameItemStateChanged(ItemEvent e) { |
1315 | - updateFontPreview(); |
1316 | - } |
1317 | - |
1318 | - private void fontSizeStateChanged(ChangeEvent e) { |
1319 | - updateFontPreview(); |
1320 | - } |
1321 | - |
1322 | - private void initComponents() { |
1323 | - // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents |
1324 | - DefaultComponentFactory compFactory = DefaultComponentFactory.getInstance(); |
1325 | - _tabPane = new JTabbedPane(); |
1326 | - JPanel paneCapture = new JPanel(); |
1327 | - _txtHotkey = new JTextField(); |
1328 | - _lblHotkey = new JLabel(); |
1329 | - _lblDelay = new JLabel(); |
1330 | - _spnDelay = new JSpinner(); |
1331 | - _lblDelaySecs = new JLabel(); |
1332 | - _lblNaming = new JLabel(); |
1333 | - _radTimestamp = new JRadioButton(); |
1334 | - _radOCR = new JRadioButton(); |
1335 | - _radOff = new JRadioButton(); |
1336 | - _paneTextEditing = new JPanel(); |
1337 | - _chkExpandTab = new JCheckBox(); |
1338 | - _lblTabWidth = new JLabel(); |
1339 | - _cmbFontName = new JComboBox(); |
1340 | - _lblFont = new JLabel(); |
1341 | - _titleAppearance = compFactory.createTitle(""); |
1342 | - _titleIndentation = compFactory.createTitle(""); |
1343 | - _spnTabWidth = new JSpinner(); |
1344 | - _lblFontSize = new JLabel(); |
1345 | - _spnFontSize = new JSpinner(); |
1346 | - JPanel paneGeneral = new JPanel(); |
1347 | - _chkAutoUpdate = new JCheckBox(); |
1348 | - _cmbLang = new JComboBox(); |
1349 | - _lblUpdates = new JLabel(); |
1350 | - _lblLanguage = new JLabel(); |
1351 | - JPanel paneOkCancel = new JPanel(); |
1352 | - JPanel hSpacer1 = new JPanel(null); |
1353 | - _btnOk = new JButton(); |
1354 | - _btnCancel = new JButton(); |
1355 | - |
1356 | - //======== this ======== |
1357 | - Container contentPane = getContentPane(); |
1358 | - contentPane.setLayout(new BorderLayout()); |
1359 | - |
1360 | - //======== _tabPane ======== |
1361 | - { |
1362 | - _tabPane.setBorder(new EmptyBorder(10, 10, 0, 10)); |
1363 | - |
1364 | - //======== paneCapture ======== |
1365 | - { |
1366 | - |
1367 | - //---- _txtHotkey ---- |
1368 | - _txtHotkey.setHorizontalAlignment(SwingConstants.RIGHT); |
1369 | - _txtHotkey.addFocusListener(new FocusAdapter() { |
1370 | - @Override |
1371 | - public void focusGained(FocusEvent e) { |
1372 | - txtHotkeyFocusGained(e); |
1373 | - } |
1374 | - }); |
1375 | - _txtHotkey.addKeyListener(new KeyAdapter() { |
1376 | - @Override |
1377 | - public void keyPressed(KeyEvent e) { |
1378 | - txtHotkeyKeyPressed(e); |
1379 | - } |
1380 | - }); |
1381 | - |
1382 | - //---- _lblHotkey ---- |
1383 | - _lblHotkey.setLabelFor(_txtHotkey); |
1384 | - |
1385 | - //---- _lblDelay ---- |
1386 | - _lblDelay.setLabelFor(_spnDelay); |
1387 | - |
1388 | - //---- _spnDelay ---- |
1389 | - _spnDelay.setModel(new SpinnerNumberModel(1.0, 0.0, null, 0.1)); |
1390 | - |
1391 | - //---- _radTimestamp ---- |
1392 | - _radTimestamp.setSelected(true); |
1393 | - |
1394 | - GroupLayout paneCaptureLayout = new GroupLayout(paneCapture); |
1395 | - paneCapture.setLayout(paneCaptureLayout); |
1396 | - paneCaptureLayout.setHorizontalGroup( |
1397 | - paneCaptureLayout.createParallelGroup() |
1398 | - .add(paneCaptureLayout.createSequentialGroup() |
1399 | - .add(26, 26, 26) |
1400 | - .add(paneCaptureLayout.createParallelGroup() |
1401 | - .add(GroupLayout.TRAILING, _lblDelay) |
1402 | - .add(GroupLayout.TRAILING, _lblHotkey) |
1403 | - .add(GroupLayout.TRAILING, _lblNaming)) |
1404 | - .addPreferredGap(LayoutStyle.RELATED) |
1405 | - .add(paneCaptureLayout.createParallelGroup() |
1406 | - .add(_radTimestamp) |
1407 | - .add(_radOCR) |
1408 | - .add(_radOff) |
1409 | - .add(paneCaptureLayout.createSequentialGroup() |
1410 | - .add(_spnDelay, GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE) |
1411 | - .addPreferredGap(LayoutStyle.RELATED) |
1412 | - .add(_lblDelaySecs, GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)) |
1413 | - .add(_txtHotkey, GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)) |
1414 | - .add(69, 69, 69)) |
1415 | - ); |
1416 | - paneCaptureLayout.setVerticalGroup( |
1417 | - paneCaptureLayout.createParallelGroup() |
1418 | - .add(paneCaptureLayout.createSequentialGroup() |
1419 | - .add(34, 34, 34) |
1420 | - .add(paneCaptureLayout.createParallelGroup(GroupLayout.BASELINE) |
1421 | - .add(_lblHotkey, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE) |
1422 | - .add(_txtHotkey, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) |
1423 | - .addPreferredGap(LayoutStyle.RELATED) |
1424 | - .add(paneCaptureLayout.createParallelGroup() |
1425 | - .add(_lblDelay, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE) |
1426 | - .add(_spnDelay, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) |
1427 | - .add(_lblDelaySecs, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)) |
1428 | - .addPreferredGap(LayoutStyle.RELATED) |
1429 | - .add(paneCaptureLayout.createParallelGroup(GroupLayout.LEADING, false) |
1430 | - .add(paneCaptureLayout.createSequentialGroup() |
1431 | - .add(paneCaptureLayout.createParallelGroup(GroupLayout.BASELINE) |
1432 | - .add(_lblNaming, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE) |
1433 | - .add(_radTimestamp)) |
1434 | - .add(18, 18, 18) |
1435 | - .add(_radOff) |
1436 | - .addPreferredGap(LayoutStyle.RELATED)) |
1437 | - .add(GroupLayout.TRAILING, paneCaptureLayout.createSequentialGroup() |
1438 | - .add(_radOCR) |
1439 | - .add(21, 21, 21))) |
1440 | - .add(80, 80, 80)) |
1441 | - ); |
1442 | - } |
1443 | - _tabPane.addTab(I18N._I("prefTabScreenCapturing"), paneCapture); |
1444 | - |
1445 | - |
1446 | - //======== _paneTextEditing ======== |
1447 | - { |
1448 | - |
1449 | - //---- _lblTabWidth ---- |
1450 | - _lblTabWidth.setLabelFor(_spnTabWidth); |
1451 | - |
1452 | - //---- _cmbFontName ---- |
1453 | - _cmbFontName.addItemListener(new ItemListener() { |
1454 | - public void itemStateChanged(ItemEvent e) { |
1455 | - fontNameItemStateChanged(e); |
1456 | - } |
1457 | - }); |
1458 | - |
1459 | - //---- _lblFont ---- |
1460 | - _lblFont.setLabelFor(_cmbFontName); |
1461 | - |
1462 | - //---- _lblFontSize ---- |
1463 | - _lblFontSize.setLabelFor(_cmbFontName); |
1464 | - |
1465 | - //---- _spnFontSize ---- |
1466 | - _spnFontSize.addChangeListener(new ChangeListener() { |
1467 | - public void stateChanged(ChangeEvent e) { |
1468 | - fontSizeStateChanged(e); |
1469 | - } |
1470 | - }); |
1471 | - |
1472 | - GroupLayout _paneTextEditingLayout = new GroupLayout(_paneTextEditing); |
1473 | - _paneTextEditing.setLayout(_paneTextEditingLayout); |
1474 | - _paneTextEditingLayout.setHorizontalGroup( |
1475 | - _paneTextEditingLayout.createParallelGroup() |
1476 | - .add(GroupLayout.TRAILING, _paneTextEditingLayout.createSequentialGroup() |
1477 | - .add(95, 95, 95) |
1478 | - .add(_paneTextEditingLayout.createParallelGroup() |
1479 | - .add(_titleIndentation, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) |
1480 | - .add(_paneTextEditingLayout.createSequentialGroup() |
1481 | - .add(_titleAppearance, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) |
1482 | - .addPreferredGap(LayoutStyle.RELATED) |
1483 | - .add(_paneTextEditingLayout.createParallelGroup() |
1484 | - .add(_paneTextEditingLayout.createSequentialGroup() |
1485 | - .add(29, 29, 29) |
1486 | - .add(_paneTextEditingLayout.createParallelGroup() |
1487 | - .add(GroupLayout.TRAILING, _lblTabWidth) |
1488 | - .add(GroupLayout.TRAILING, _lblFont) |
1489 | - .add(GroupLayout.TRAILING, _lblFontSize)) |
1490 | - .addPreferredGap(LayoutStyle.RELATED) |
1491 | - .add(_paneTextEditingLayout.createParallelGroup() |
1492 | - .add(_cmbFontName, 0, 218, Short.MAX_VALUE) |
1493 | - .add(_spnFontSize, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE) |
1494 | - .add(_spnTabWidth, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE)) |
1495 | - .addPreferredGap(LayoutStyle.RELATED, 97, Short.MAX_VALUE)) |
1496 | - .add(_chkExpandTab, GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE)))) |
1497 | - .addContainerGap()) |
1498 | - ); |
1499 | - _paneTextEditingLayout.setVerticalGroup( |
1500 | - _paneTextEditingLayout.createParallelGroup() |
1501 | - .add(_paneTextEditingLayout.createSequentialGroup() |
1502 | - .add(21, 21, 21) |
1503 | - .add(_titleIndentation, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) |
1504 | - .add(_paneTextEditingLayout.createParallelGroup() |
1505 | - .add(_paneTextEditingLayout.createSequentialGroup() |
1506 | - .add(81, 81, 81) |
1507 | - .add(_titleAppearance, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) |
1508 | - .add(_paneTextEditingLayout.createSequentialGroup() |
1509 | - .addPreferredGap(LayoutStyle.RELATED) |
1510 | - .add(_chkExpandTab) |
1511 | - .addPreferredGap(LayoutStyle.RELATED) |
1512 | - .add(_paneTextEditingLayout.createParallelGroup() |
1513 | - .add(_lblTabWidth, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE) |
1514 | - .add(_spnTabWidth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) |
1515 | - .add(40, 40, 40) |
1516 | - .add(_paneTextEditingLayout.createParallelGroup(GroupLayout.BASELINE) |
1517 | - .add(_lblFont) |
1518 | - .add(_cmbFontName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) |
1519 | - .addPreferredGap(LayoutStyle.RELATED) |
1520 | - .add(_paneTextEditingLayout.createParallelGroup(GroupLayout.TRAILING) |
1521 | - .add(_lblFontSize, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE) |
1522 | - .add(_spnFontSize, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))) |
1523 | - .addContainerGap(154, Short.MAX_VALUE)) |
1524 | - ); |
1525 | - _paneTextEditingLayout.linkSize(new Component[] {_lblTabWidth, _spnTabWidth}, GroupLayout.VERTICAL); |
1526 | - _paneTextEditingLayout.linkSize(new Component[] {_cmbFontName, _lblFont}, GroupLayout.VERTICAL); |
1527 | - } |
1528 | - _tabPane.addTab(I18N._I("PreferencesWin.paneTextEditing.tab.title"), _paneTextEditing); |
1529 | - |
1530 | - |
1531 | - //======== paneGeneral ======== |
1532 | - { |
1533 | - |
1534 | - //---- _lblUpdates ---- |
1535 | - _lblUpdates.setFont(_lblUpdates.getFont().deriveFont(_lblUpdates.getFont().getStyle() | Font.BOLD)); |
1536 | - |
1537 | - //---- _lblLanguage ---- |
1538 | - _lblLanguage.setFont(_lblLanguage.getFont().deriveFont(_lblLanguage.getFont().getStyle() | Font.BOLD)); |
1539 | - |
1540 | - GroupLayout paneGeneralLayout = new GroupLayout(paneGeneral); |
1541 | - paneGeneral.setLayout(paneGeneralLayout); |
1542 | - paneGeneralLayout.setHorizontalGroup( |
1543 | - paneGeneralLayout.createParallelGroup() |
1544 | - .add(paneGeneralLayout.createSequentialGroup() |
1545 | - .add(137, 137, 137) |
1546 | - .add(paneGeneralLayout.createParallelGroup() |
1547 | - .add(paneGeneralLayout.createSequentialGroup() |
1548 | - .add(_lblLanguage) |
1549 | - .add(185, 185, 185)) |
1550 | - .add(paneGeneralLayout.createSequentialGroup() |
1551 | - .add(38, 38, 38) |
1552 | - .add(_cmbLang, GroupLayout.PREFERRED_SIZE, 215, GroupLayout.PREFERRED_SIZE)) |
1553 | - .add(paneGeneralLayout.createSequentialGroup() |
1554 | - .add(_lblUpdates) |
1555 | - .add(318, 318, 318)) |
1556 | - .add(GroupLayout.TRAILING, paneGeneralLayout.createSequentialGroup() |
1557 | - .add(38, 38, 38) |
1558 | - .add(_chkAutoUpdate, GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))) |
1559 | - .addContainerGap()) |
1560 | - ); |
1561 | - paneGeneralLayout.setVerticalGroup( |
1562 | - paneGeneralLayout.createParallelGroup() |
1563 | - .add(paneGeneralLayout.createSequentialGroup() |
1564 | - .add(26, 26, 26) |
1565 | - .add(_lblUpdates) |
1566 | - .addPreferredGap(LayoutStyle.RELATED) |
1567 | - .add(_chkAutoUpdate) |
1568 | - .add(40, 40, 40) |
1569 | - .add(_lblLanguage) |
1570 | - .addPreferredGap(LayoutStyle.RELATED) |
1571 | - .add(_cmbLang, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) |
1572 | - .addContainerGap(196, Short.MAX_VALUE)) |
1573 | - ); |
1574 | - } |
1575 | - _tabPane.addTab(I18N._I("prefTabGeneralSettings"), paneGeneral); |
1576 | - |
1577 | - } |
1578 | - contentPane.add(_tabPane, BorderLayout.CENTER); |
1579 | - |
1580 | - //======== paneOkCancel ======== |
1581 | - { |
1582 | - paneOkCancel.setBorder(new EmptyBorder(5, 5, 5, 5)); |
1583 | - paneOkCancel.setLayout(new BoxLayout(paneOkCancel, BoxLayout.X_AXIS)); |
1584 | - paneOkCancel.add(hSpacer1); |
1585 | - |
1586 | - //---- _btnOk ---- |
1587 | - _btnOk.addActionListener(new ActionListener() { |
1588 | - public void actionPerformed(ActionEvent e) { |
1589 | - btnOkActionPerformed(e); |
1590 | - } |
1591 | - }); |
1592 | - paneOkCancel.add(_btnOk); |
1593 | - |
1594 | - //---- _btnCancel ---- |
1595 | - _btnCancel.addActionListener(new ActionListener() { |
1596 | - public void actionPerformed(ActionEvent e) { |
1597 | - btnCancelActionPerformed(e); |
1598 | - } |
1599 | - }); |
1600 | - paneOkCancel.add(_btnCancel); |
1601 | - } |
1602 | - contentPane.add(paneOkCancel, BorderLayout.SOUTH); |
1603 | - setSize(600, 475); |
1604 | - setLocationRelativeTo(getOwner()); |
1605 | - |
1606 | - //---- btngrpNaming ---- |
1607 | - ButtonGroup btngrpNaming = new ButtonGroup(); |
1608 | - btngrpNaming.add(_radTimestamp); |
1609 | - btngrpNaming.add(_radOCR); |
1610 | - btngrpNaming.add(_radOff); |
1611 | - |
1612 | - initComponentsI18n(); |
1613 | - // JFormDesigner - End of component initialization //GEN-END:initComponents |
1614 | - } |
1615 | - |
1616 | - private void initComponentsI18n() { |
1617 | - // JFormDesigner - Component i18n initialization - DO NOT MODIFY //GEN-BEGIN:initI18n |
1618 | - DefaultComponentFactory.setTextAndMnemonic(_titleAppearance, I18N._I("PreferencesWin.titleAppearance.textWithMnemonic")); |
1619 | - DefaultComponentFactory.setTextAndMnemonic(_titleIndentation, I18N._I("PreferencesWin.titleIndentation.textWithMnemonic")); |
1620 | - _lblHotkey.setText(I18N._I("prefCaptureHotkey")); |
1621 | - _lblDelay.setText(I18N._I("prefCaptureDelay")); |
1622 | - _lblDelaySecs.setText(I18N._I("prefSeconds")); |
1623 | - _lblNaming.setText(I18N._I("prefAutoNaming")); |
1624 | - _radTimestamp.setText(I18N._I("prefTimestamp")); |
1625 | - _radOCR.setText(I18N._I("prefRecognizedText")); |
1626 | - _radOff.setText(I18N._I("prefManualInput")); |
1627 | - _tabPane.setTitleAt(0, I18N._I("prefTabScreenCapturing")); |
1628 | - _chkExpandTab.setText(I18N._I("PreferencesWin.chkExpandTab.text")); |
1629 | - _lblTabWidth.setText(I18N._I("PreferencesWin.lblTabWidth.text")); |
1630 | - _lblFont.setText(I18N._I("PreferencesWin.lblFont.text")); |
1631 | - _lblFontSize.setText(I18N._I("PreferencesWin.lblFontSize.text")); |
1632 | - _tabPane.setTitleAt(1, I18N._I("PreferencesWin.paneTextEditing.tab.title")); |
1633 | - _chkAutoUpdate.setText(I18N._I("prefGeneralAutoCheck")); |
1634 | - _lblUpdates.setText(I18N._I("PreferencesWin.lblUpdates.text")); |
1635 | - _lblLanguage.setText(I18N._I("PreferencesWin.lblLanguage.text")); |
1636 | - _tabPane.setTitleAt(2, I18N._I("prefTabGeneralSettings")); |
1637 | - _btnOk.setText(I18N._I("ok")); |
1638 | - _btnCancel.setText(I18N._I("cancel")); |
1639 | - // JFormDesigner - End of component i18n initialization //GEN-END:initI18n |
1640 | - } |
1641 | - |
1642 | - // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables |
1643 | - private JTabbedPane _tabPane; |
1644 | - private JTextField _txtHotkey; |
1645 | - private JLabel _lblHotkey; |
1646 | - private JLabel _lblDelay; |
1647 | - private JSpinner _spnDelay; |
1648 | - private JLabel _lblDelaySecs; |
1649 | - private JLabel _lblNaming; |
1650 | - private JRadioButton _radTimestamp; |
1651 | - private JRadioButton _radOCR; |
1652 | - private JRadioButton _radOff; |
1653 | - private JPanel _paneTextEditing; |
1654 | - private JCheckBox _chkExpandTab; |
1655 | - private JLabel _lblTabWidth; |
1656 | - private JComboBox _cmbFontName; |
1657 | - private JLabel _lblFont; |
1658 | - private JLabel _titleAppearance; |
1659 | - private JLabel _titleIndentation; |
1660 | - private JSpinner _spnTabWidth; |
1661 | - private JLabel _lblFontSize; |
1662 | - private JSpinner _spnFontSize; |
1663 | - private JCheckBox _chkAutoUpdate; |
1664 | - private JComboBox _cmbLang; |
1665 | - private JLabel _lblUpdates; |
1666 | - private JLabel _lblLanguage; |
1667 | - private JButton _btnOk; |
1668 | - private JButton _btnCancel; |
1669 | - // JFormDesigner - End of variables declaration //GEN-END:variables |
1670 | -} |
1671 | - |
1672 | -class LocaleListCellRenderer extends DefaultListCellRenderer { |
1673 | - public Component getListCellRendererComponent(JList list, |
1674 | - Object value, int index, boolean isSelected, boolean hasFocus) { |
1675 | - Locale locale = (Locale) (value); |
1676 | - return super.getListCellRendererComponent(list, |
1677 | - locale.getDisplayName(locale), index, isSelected, hasFocus); |
1678 | - } |
1679 | -} |
1680 | - |
1681 | |
1682 | === removed directory '.pc/native.patch' |
1683 | === removed directory '.pc/native.patch/sikuli-script' |
1684 | === removed directory '.pc/native.patch/sikuli-script/src' |
1685 | === removed directory '.pc/native.patch/sikuli-script/src/main' |
1686 | === removed directory '.pc/native.patch/sikuli-script/src/main/java' |
1687 | === removed directory '.pc/native.patch/sikuli-script/src/main/java/org' |
1688 | === removed directory '.pc/native.patch/sikuli-script/src/main/java/org/sikuli' |
1689 | === removed directory '.pc/native.patch/sikuli-script/src/main/java/org/sikuli/script' |
1690 | === removed file '.pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/Finder.java' |
1691 | --- .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/Finder.java 2012-02-15 15:17:58 +0000 |
1692 | +++ .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/Finder.java 1970-01-01 00:00:00 +0000 |
1693 | @@ -1,195 +0,0 @@ |
1694 | -/* |
1695 | - * Copyright 2010-2011, Sikuli.org |
1696 | - * Released under the MIT License. |
1697 | - * |
1698 | - */ |
1699 | -package org.sikuli.script; |
1700 | - |
1701 | -import java.awt.*; |
1702 | -import java.util.Iterator; |
1703 | -import java.io.File; |
1704 | -import java.io.IOException; |
1705 | -import java.io.FileNotFoundException; |
1706 | - |
1707 | -import org.sikuli.script.natives.FindInput; |
1708 | -import org.sikuli.script.natives.FindResult; |
1709 | -import org.sikuli.script.natives.FindResults; |
1710 | -import org.sikuli.script.natives.Mat; |
1711 | -import org.sikuli.script.natives.TARGET_TYPE; |
1712 | -import org.sikuli.script.natives.Vision; |
1713 | - |
1714 | -import com.wapmx.nativeutils.jniloader.NativeLoader; |
1715 | - |
1716 | -public class Finder implements Iterator<Match>{ |
1717 | - private Region _region = null; |
1718 | - private Pattern _pattern = null; |
1719 | - private FindInput _findInput = new FindInput(); |
1720 | - private FindResults _results = null; |
1721 | - private ImageLocator _imgLocator = null; |
1722 | - private int _cur_result_i; |
1723 | - |
1724 | - static { |
1725 | - try{ |
1726 | - NativeLoader.loadLibrary("VisionProxy"); |
1727 | - Debug.info("Sikuli vision engine loaded."); |
1728 | - } |
1729 | - catch(IOException e){ |
1730 | - e.printStackTrace(); |
1731 | - } |
1732 | - //Vision.setParameter("GPU", 1); |
1733 | - } |
1734 | - |
1735 | - public Finder __enter__(){ |
1736 | - return this; |
1737 | - } |
1738 | - |
1739 | - public void __exit__(Object type, Object value, Object trackback){ |
1740 | - destroy(); |
1741 | - } |
1742 | - |
1743 | - /** |
1744 | - * Finder constructor (finding within the desktop screen). |
1745 | - */ |
1746 | - public Finder(String screenFilename) throws IOException{ |
1747 | - this(screenFilename, null); |
1748 | - } |
1749 | - |
1750 | - /** |
1751 | - * Finder constructor (finding within the given region). |
1752 | - */ |
1753 | - public Finder(String screenFilename, Region region) throws IOException{ |
1754 | - String fname = findImageFile(screenFilename); |
1755 | - _findInput.setSource(fname); |
1756 | - _region = region; |
1757 | - } |
1758 | - |
1759 | - /** |
1760 | - * Finder constructor (finding within the given region). |
1761 | - */ |
1762 | - public Finder(ScreenImage img, Region region){ |
1763 | - Mat target = OpenCV.convertBufferedImageToMat(img.getImage()); |
1764 | - _findInput.setSource(target); |
1765 | - _region = region; |
1766 | - } |
1767 | - |
1768 | - public void __del__(){ |
1769 | - destroy(); |
1770 | - } |
1771 | - |
1772 | - protected void finalize() throws Throwable { |
1773 | - destroy(); |
1774 | - } |
1775 | - |
1776 | - protected String findImageFile(String file) throws IOException{ |
1777 | - if(_imgLocator == null) |
1778 | - _imgLocator = new ImageLocator(); |
1779 | - return _imgLocator.locate(file); |
1780 | - } |
1781 | - |
1782 | - protected <PSC> void setFindInput(PSC ptn) throws IOException{ |
1783 | - if( ptn instanceof Pattern ){ |
1784 | - _pattern = (Pattern)ptn; |
1785 | - Mat targetMat = OpenCV.convertBufferedImageToMat(_pattern.getImage()); |
1786 | - _findInput.setTarget(targetMat); |
1787 | - _findInput.setSimilarity(_pattern.similarity); |
1788 | - } |
1789 | - else if( ptn instanceof String){ |
1790 | - setTargetSmartly(_findInput, (String)ptn); |
1791 | - _findInput.setSimilarity(Settings.MinSimilarity); |
1792 | - } |
1793 | - } |
1794 | - |
1795 | - protected void setTargetSmartly(FindInput fin, String target){ |
1796 | - try{ |
1797 | - //assume it's a file first |
1798 | - String filename = findImageFile(target); |
1799 | - fin.setTarget(TARGET_TYPE.IMAGE, filename); |
1800 | - } |
1801 | - catch(IOException e){ |
1802 | - if(Util.isImageFile(target)) |
1803 | - Debug.error(target + " looks like a file, but can't be found on the disk. Assume it's text." ); |
1804 | - // this will init text recognizer on demand |
1805 | - TextRecognizer tr = TextRecognizer.getInstance(); |
1806 | - //assume it's text |
1807 | - fin.setTarget(TARGET_TYPE.TEXT, target); |
1808 | - } |
1809 | - } |
1810 | - |
1811 | - |
1812 | - |
1813 | - /** |
1814 | - * void find( Pattern/String/PatternClass ) |
1815 | - * finds the given pattern in the given ScreenImage. |
1816 | - */ |
1817 | - public <PSC> void find(PSC ptn) throws IOException{ |
1818 | - setFindInput(ptn); |
1819 | - _results = Vision.find(_findInput); |
1820 | - _cur_result_i = 0; |
1821 | - } |
1822 | - |
1823 | - public void find(String templateFilename, double minSimilarity) throws IOException{ |
1824 | - setTargetSmartly(_findInput, templateFilename); |
1825 | - _findInput.setSimilarity(minSimilarity); |
1826 | - _results = Vision.find(_findInput); |
1827 | - _cur_result_i = 0; |
1828 | - } |
1829 | - |
1830 | - public <PSC> void findAll(PSC ptn) throws IOException { |
1831 | - Debug timing = new Debug(); |
1832 | - timing.startTiming("Finder.findAll"); |
1833 | - |
1834 | - setFindInput(ptn); |
1835 | - _findInput.setFindAll(true); |
1836 | - _results = Vision.find(_findInput); |
1837 | - _cur_result_i = 0; |
1838 | - |
1839 | - timing.endTiming("Finder.findAll"); |
1840 | - } |
1841 | - |
1842 | - public void findAll(String templateFilename, double minSimilarity) throws IOException { |
1843 | - Debug timing = new Debug(); |
1844 | - timing.startTiming("Finder.findAll"); |
1845 | - |
1846 | - setTargetSmartly(_findInput, templateFilename); |
1847 | - _findInput.setSimilarity(minSimilarity); |
1848 | - _findInput.setFindAll(true); |
1849 | - _results = Vision.find(_findInput); |
1850 | - _cur_result_i = 0; |
1851 | - |
1852 | - timing.endTiming("Finder.findAll"); |
1853 | - } |
1854 | - |
1855 | - public boolean hasNext(){ |
1856 | - if(_results != null && _results.size() > _cur_result_i) |
1857 | - return true; |
1858 | - return false; |
1859 | - } |
1860 | - |
1861 | - |
1862 | - public Match next(){ |
1863 | - Match ret = null; |
1864 | - if(hasNext()){ |
1865 | - FindResult fr = _results.get(_cur_result_i++); |
1866 | - IScreen parentScreen = null; |
1867 | - if(_region != null) |
1868 | - parentScreen = _region.getScreen(); |
1869 | - ret = new Match(fr, parentScreen); |
1870 | - if(_region != null){ |
1871 | - ret = _region.toGlobalCoord(ret); |
1872 | - } |
1873 | - if(_pattern != null){ |
1874 | - Location offset = _pattern.getTargetOffset(); |
1875 | - ret.setTargetOffset(offset); |
1876 | - } |
1877 | - } |
1878 | - return ret; |
1879 | - } |
1880 | - |
1881 | - public void remove(){ |
1882 | - } |
1883 | - |
1884 | - public void destroy(){ |
1885 | - } |
1886 | - |
1887 | -} |
1888 | - |
1889 | |
1890 | === removed file '.pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/TextRecognizer.java' |
1891 | --- .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/TextRecognizer.java 2012-02-15 15:17:58 +0000 |
1892 | +++ .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/TextRecognizer.java 1970-01-01 00:00:00 +0000 |
1893 | @@ -1,120 +0,0 @@ |
1894 | -/* |
1895 | - * Copyright 2010-2011, Sikuli.org |
1896 | - * Released under the MIT License. |
1897 | - * |
1898 | - */ |
1899 | -package org.sikuli.script; |
1900 | - |
1901 | -import java.awt.image.*; |
1902 | -import java.io.*; |
1903 | -import java.net.URL; |
1904 | -import java.util.Enumeration; |
1905 | -import java.util.List; |
1906 | -import java.util.LinkedList; |
1907 | - |
1908 | -import org.sikuli.script.natives.Mat; |
1909 | -import org.sikuli.script.natives.Vision; |
1910 | -import org.sikuli.script.natives.OCRWord; |
1911 | -import org.sikuli.script.natives.OCRWords; |
1912 | - |
1913 | -import com.wapmx.nativeutils.jniloader.NativeLoader; |
1914 | - |
1915 | -// Singleton |
1916 | -public class TextRecognizer { |
1917 | - protected static TextRecognizer _instance = null; |
1918 | - |
1919 | - static { |
1920 | - try{ |
1921 | - NativeLoader.loadLibrary("VisionProxy"); |
1922 | - TextRecognizer tr = TextRecognizer.getInstance(); |
1923 | - } |
1924 | - catch(IOException e){ |
1925 | - e.printStackTrace(); |
1926 | - } |
1927 | - } |
1928 | - |
1929 | - protected TextRecognizer(){ |
1930 | - init(); |
1931 | - } |
1932 | - |
1933 | - boolean _init_succeeded = false; |
1934 | - |
1935 | - public void init(){ |
1936 | - Debug.info("Text Recognizer inited."); |
1937 | - try{ |
1938 | - String path = ResourceExtractor.extract("tessdata"); |
1939 | - // TESSDATA_PREFIX doesn't contain tessdata/ |
1940 | - if(path.endsWith("tessdata/")) |
1941 | - path = path.substring(0,path.length()-9); |
1942 | - Settings.OcrDataPath = path; |
1943 | - Debug.log(3, "OCR data path: " + path); |
1944 | - |
1945 | - Vision.initOCR(Settings.OcrDataPath); |
1946 | - _init_succeeded = true; |
1947 | - } |
1948 | - catch(IOException e){ |
1949 | - e.printStackTrace(); |
1950 | - }catch(Exception e){ |
1951 | - e.printStackTrace(); |
1952 | - } |
1953 | - } |
1954 | - |
1955 | - public static TextRecognizer getInstance(){ |
1956 | - if(_instance==null) |
1957 | - _instance = new TextRecognizer(); |
1958 | - return _instance; |
1959 | - } |
1960 | - |
1961 | - public enum ListTextMode { |
1962 | - WORD, LINE, PARAGRAPH |
1963 | - }; |
1964 | - |
1965 | - public List<Match> listText(ScreenImage simg, Region parent){ |
1966 | - return listText(simg, parent, ListTextMode.WORD); |
1967 | - } |
1968 | - |
1969 | - //TODO: support LINE and PARAGRAPH |
1970 | - // listText only supports WORD mode now. |
1971 | - public List<Match> listText(ScreenImage simg, Region parent, ListTextMode mode){ |
1972 | - Mat mat = OpenCV.convertBufferedImageToMat(simg.getImage()); |
1973 | - OCRWords words = Vision.recognize_as_ocrtext(mat).getWords(); |
1974 | - List<Match> ret = new LinkedList<Match>(); |
1975 | - for(int i=0;i<words.size();i++){ |
1976 | - OCRWord w = words.get(i); |
1977 | - Match m = new Match(parent.x+w.getX(), parent.y+w.getY(), w.getWidth(), w.getHeight(), |
1978 | - w.getScore(), parent.getScreen(), w.getString()); |
1979 | - ret.add(m); |
1980 | - } |
1981 | - return ret; |
1982 | - } |
1983 | - |
1984 | - |
1985 | - public String recognize(ScreenImage simg){ |
1986 | - BufferedImage img = simg.getImage(); |
1987 | - return recognize(img); |
1988 | - } |
1989 | - |
1990 | - public String recognize(BufferedImage img){ |
1991 | - if (_init_succeeded){ |
1992 | - Mat mat = OpenCV.convertBufferedImageToMat(img); |
1993 | - return Vision.recognize(mat).trim(); |
1994 | - }else{ |
1995 | - return ""; |
1996 | - } |
1997 | - } |
1998 | - |
1999 | - public String recognizeWord(ScreenImage simg){ |
2000 | - BufferedImage img = simg.getImage(); |
2001 | - return recognizeWord(img); |
2002 | - } |
2003 | - |
2004 | - public String recognizeWord(BufferedImage img){ |
2005 | - if (_init_succeeded){ |
2006 | - Mat mat = OpenCV.convertBufferedImageToMat(img); |
2007 | - return Vision.recognizeWord(mat).trim(); |
2008 | - }else{ |
2009 | - return ""; |
2010 | - } |
2011 | - } |
2012 | -} |
2013 | - |
2014 | |
2015 | === removed file '.pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/VDictProxy.java' |
2016 | --- .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/VDictProxy.java 2011-10-04 00:57:09 +0000 |
2017 | +++ .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/VDictProxy.java 1970-01-01 00:00:00 +0000 |
2018 | @@ -1,118 +0,0 @@ |
2019 | -/* |
2020 | - * Copyright 2010-2011, Sikuli.org |
2021 | - * Released under the MIT License. |
2022 | - * |
2023 | - */ |
2024 | -package org.sikuli.script; |
2025 | - |
2026 | -import java.io.File; |
2027 | -import java.io.IOException; |
2028 | -import java.io.FileNotFoundException; |
2029 | -import java.util.Vector; |
2030 | -import java.util.HashMap; |
2031 | -import java.util.Map; |
2032 | -import java.util.List; |
2033 | -import com.wapmx.nativeutils.jniloader.NativeLoader; |
2034 | - |
2035 | -public class VDictProxy<T> { |
2036 | - private long _instance; |
2037 | - private Map<Integer, T> _i2obj = new HashMap<Integer, T>(); |
2038 | - |
2039 | - static { |
2040 | - // load libScreenMatchProxy.{so,jnilib} |
2041 | - //System.loadLibrary("ScreenMatchProxy"); |
2042 | - try{ |
2043 | - NativeLoader.loadLibrary("VDictProxy"); |
2044 | - Debug.info("VDictProxy loaded."); |
2045 | - } |
2046 | - catch(IOException e){ |
2047 | - e.printStackTrace(); |
2048 | - } |
2049 | - } |
2050 | - |
2051 | - public VDictProxy(){ |
2052 | - _instance = getInstance(); |
2053 | - } |
2054 | - |
2055 | - private native long getInstance(); |
2056 | - |
2057 | - private String getAbsolutePath(String filename) throws FileNotFoundException{ |
2058 | - if(new File(filename).exists()) |
2059 | - return filename; |
2060 | - filename = Settings.BundlePath + File.separator + filename; |
2061 | - if(new File(filename).exists()) |
2062 | - return filename; |
2063 | - throw new FileNotFoundException("No such file: " + filename); |
2064 | - } |
2065 | - |
2066 | - // insert an (key,value) entry using an image key |
2067 | - public void insert(String imagekey_filename, T value) throws FileNotFoundException { |
2068 | - imagekey_filename = getAbsolutePath(imagekey_filename); |
2069 | - int hash = value.hashCode(); |
2070 | - while(true){ |
2071 | - if( hash != -1 && !_i2obj.containsKey(hash) ){ |
2072 | - _i2obj.put(hash, value); |
2073 | - break; |
2074 | - } |
2075 | - else{ |
2076 | - hash += (int)(Math.random()*100); |
2077 | - } |
2078 | - } |
2079 | - _insert(_instance, imagekey_filename, hash); |
2080 | - } |
2081 | - |
2082 | - public native void _insert(long instance, String imagekey_filename, int value); |
2083 | - |
2084 | - // lookup the entry using an image key (exact match) |
2085 | - public T lookup(String imagekey_filename) throws FileNotFoundException{ |
2086 | - imagekey_filename = getAbsolutePath(imagekey_filename); |
2087 | - int hash = _lookup(_instance, imagekey_filename); |
2088 | - if(hash==-1) return null; |
2089 | - return _i2obj.get(hash); |
2090 | - } |
2091 | - |
2092 | - private native int _lookup(long instance, String imagekey_filename); |
2093 | - |
2094 | - // lookup the first entry with a similar image key |
2095 | - public T lookup_similar(String imagekey_filename, double similarity_threshold) throws FileNotFoundException{ |
2096 | - imagekey_filename = getAbsolutePath(imagekey_filename); |
2097 | - int hash = _lookup_similar(_instance, imagekey_filename, similarity_threshold); |
2098 | - if(hash==-1) return null; |
2099 | - return _i2obj.get(hash); |
2100 | - } |
2101 | - |
2102 | - private native int _lookup_similar(long instance, String imagekey_filename, double similarity_threshold); |
2103 | - |
2104 | - // lookup at most n entries with keys similar to the given image (n = 0 : all) |
2105 | - public List<T> lookup_similar_n(String imagekey_filename, double similarity_threshold, int n) throws FileNotFoundException{ |
2106 | - imagekey_filename = getAbsolutePath(imagekey_filename); |
2107 | - int h[] = _lookup_similar_n(_instance, imagekey_filename, similarity_threshold, n); |
2108 | - List<T> ret = new Vector<T>(h.length); |
2109 | - for(int i=0;i<h.length;i++){ |
2110 | - if(h[i] == -1) |
2111 | - ret.add(i, null); |
2112 | - else |
2113 | - ret.add(i, _i2obj.get(h[i])); |
2114 | - } |
2115 | - return ret; |
2116 | - } |
2117 | - |
2118 | - private native int[] _lookup_similar_n(long instance, String imagekey_filename, double similarity_threshold, int n); |
2119 | - |
2120 | - // erase the entry associated with the image |
2121 | - public void erase(String imagekey_filename) throws FileNotFoundException{ |
2122 | - imagekey_filename = getAbsolutePath(imagekey_filename); |
2123 | - int h = _lookup(_instance, imagekey_filename); |
2124 | - if(h!=-1) _i2obj.remove(h); |
2125 | - _erase(_instance, imagekey_filename); |
2126 | - } |
2127 | - |
2128 | - private native void _erase(long _instance, String imagekey_filename); |
2129 | - |
2130 | - public int size(){ return _size(_instance); } |
2131 | - private native int _size(long instance); // return the number of image keys stored |
2132 | - |
2133 | - public boolean empty(){ return _empty(_instance); } |
2134 | - private native boolean _empty(long instance); // test whether it is empty |
2135 | -} |
2136 | - |
2137 | |
2138 | === removed directory '.pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/internal' |
2139 | === removed directory '.pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/internal/hotkey' |
2140 | === removed file '.pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/internal/hotkey/LinuxHotkeyManager.java' |
2141 | --- .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/internal/hotkey/LinuxHotkeyManager.java 2011-10-04 00:57:09 +0000 |
2142 | +++ .pc/native.patch/sikuli-script/src/main/java/org/sikuli/script/internal/hotkey/LinuxHotkeyManager.java 1970-01-01 00:00:00 +0000 |
2143 | @@ -1,106 +0,0 @@ |
2144 | -/* |
2145 | - * Copyright 2010-2011, Sikuli.org |
2146 | - * Released under the MIT License. |
2147 | - * |
2148 | - */ |
2149 | -package org.sikuli.script.internal.hotkey; |
2150 | - |
2151 | -import java.lang.reflect.*; |
2152 | -import java.awt.Event; |
2153 | -import java.awt.event.*; |
2154 | -import java.util.*; |
2155 | -import java.io.IOException; |
2156 | - |
2157 | -import org.sikuli.script.Debug; |
2158 | -import org.sikuli.script.HotkeyListener; |
2159 | -import org.sikuli.script.HotkeyEvent; |
2160 | - |
2161 | -import com.wapmx.nativeutils.jniloader.NativeLoader; |
2162 | -import jxgrabkey.HotkeyConflictException; |
2163 | -import jxgrabkey.JXGrabKey; |
2164 | - |
2165 | -public class LinuxHotkeyManager extends HotkeyManager { |
2166 | - static{ |
2167 | - try{ |
2168 | - NativeLoader.loadLibrary("JXGrabKey"); |
2169 | - } |
2170 | - catch(IOException e){ |
2171 | - Debug.error("Can't load native lib JXGrabKey"); |
2172 | - e.printStackTrace(); |
2173 | - } |
2174 | - } |
2175 | - |
2176 | - class HotkeyData { |
2177 | - int key, modifiers; |
2178 | - HotkeyListener listener; |
2179 | - |
2180 | - public HotkeyData(int key_, int mod_, HotkeyListener l_){ |
2181 | - key = key_; |
2182 | - modifiers = mod_; |
2183 | - listener = l_; |
2184 | - } |
2185 | - }; |
2186 | - |
2187 | - class MyHotkeyHandler implements jxgrabkey.HotkeyListener{ |
2188 | - public void onHotkey(int id){ |
2189 | - Debug.log(4, "Hotkey pressed"); |
2190 | - HotkeyData data = _idCallbackMap.get(id); |
2191 | - HotkeyEvent e = new HotkeyEvent(data.key, data.modifiers); |
2192 | - data.listener.invokeHotkeyPressed(e); |
2193 | - } |
2194 | - }; |
2195 | - |
2196 | - private Map<Integer, HotkeyData> _idCallbackMap = new HashMap<Integer,HotkeyData >(); |
2197 | - private int _gHotkeyId = 1; |
2198 | - |
2199 | - public boolean _addHotkey(int keyCode, int modifiers, HotkeyListener listener){ |
2200 | - JXGrabKey grabKey = JXGrabKey.getInstance(); |
2201 | - |
2202 | - if(_gHotkeyId == 1){ |
2203 | - grabKey.addHotkeyListener(new MyHotkeyHandler()); |
2204 | - } |
2205 | - |
2206 | - _removeHotkey(keyCode, modifiers); |
2207 | - int id = _gHotkeyId++; |
2208 | - HotkeyData data = new HotkeyData(keyCode, modifiers, listener); |
2209 | - _idCallbackMap.put(id, data); |
2210 | - |
2211 | - try{ |
2212 | - //JXGrabKey.setDebugOutput(true); |
2213 | - grabKey.registerAwtHotkey(id, modifiers, keyCode); |
2214 | - }catch(HotkeyConflictException e){ |
2215 | - Debug.error("Hot key conflicts"); |
2216 | - return false; |
2217 | - } |
2218 | - return true; |
2219 | - } |
2220 | - |
2221 | - public boolean _removeHotkey(int keyCode, int modifiers){ |
2222 | - for( Map.Entry<Integer, HotkeyData> entry : _idCallbackMap.entrySet() ){ |
2223 | - HotkeyData data = entry.getValue(); |
2224 | - if(data.key == keyCode && data.modifiers == modifiers){ |
2225 | - JXGrabKey grabKey = JXGrabKey.getInstance(); |
2226 | - int id = entry.getKey(); |
2227 | - grabKey.unregisterHotKey(id); |
2228 | - _idCallbackMap.remove(id); |
2229 | - return true; |
2230 | - } |
2231 | - } |
2232 | - return false; |
2233 | - } |
2234 | - |
2235 | - |
2236 | - public void cleanUp(){ |
2237 | - JXGrabKey grabKey = JXGrabKey.getInstance(); |
2238 | - for( Map.Entry<Integer, HotkeyData> entry : _idCallbackMap.entrySet() ){ |
2239 | - int id = entry.getKey(); |
2240 | - grabKey.unregisterHotKey(id); |
2241 | - } |
2242 | - _gHotkeyId = 1; |
2243 | - _idCallbackMap.clear(); |
2244 | - grabKey.getInstance().cleanUp(); |
2245 | - } |
2246 | - |
2247 | -} |
2248 | - |
2249 | - |
2250 | |
2251 | === removed directory '.pc/native.patch/sikuli-script/src/main/native' |
2252 | === removed file '.pc/native.patch/sikuli-script/src/main/native/vision.i' |
2253 | --- .pc/native.patch/sikuli-script/src/main/native/vision.i 2012-02-15 15:17:58 +0000 |
2254 | +++ .pc/native.patch/sikuli-script/src/main/native/vision.i 1970-01-01 00:00:00 +0000 |
2255 | @@ -1,264 +0,0 @@ |
2256 | -%module VisionProxy |
2257 | -%{ |
2258 | -#include "vision.h" |
2259 | -#include "sikuli-debug.h" |
2260 | -#include <iostream> |
2261 | -#include "opencv.hpp" |
2262 | -#include "cvgui.h" |
2263 | -#include "tessocr.h" |
2264 | -%} |
2265 | - |
2266 | -%include "std_vector.i" |
2267 | -%include "std_string.i" |
2268 | -%include "typemaps.i" |
2269 | -%include "various.i" |
2270 | - |
2271 | -%pragma(java) jniclassimports=%{ |
2272 | - import com.wapmx.nativeutils.jniloader.NativeLoader; |
2273 | -%} |
2274 | - |
2275 | -%pragma(java) jniclasscode=%{ |
2276 | - static { |
2277 | - try { |
2278 | - NativeLoader.loadLibrary("VisionProxy"); |
2279 | - } catch (Exception e) { |
2280 | - System.err.println("Failed to load VisionProxy.\n" + e); |
2281 | - } |
2282 | - } |
2283 | -%} |
2284 | - |
2285 | - |
2286 | -%template(FindResults) std::vector<FindResult>; |
2287 | - |
2288 | -%template(OCRChars) std::vector<OCRChar>; |
2289 | -%template(OCRWords) std::vector<OCRWord>; |
2290 | -%template(OCRLines) std::vector<OCRLine>; |
2291 | -%template(OCRParagraphs) std::vector<OCRParagraph>; |
2292 | - |
2293 | -%typemap(jni) unsigned char* "jbyteArray" |
2294 | -%typemap(jtype) unsigned char* "byte[]" |
2295 | -%typemap(jstype) unsigned char* "byte[]" |
2296 | - |
2297 | -// Map input argument: java byte[] -> C++ unsigned char * |
2298 | -%typemap(in) unsigned char* { |
2299 | - long len = JCALL1(GetArrayLength, jenv, $input); |
2300 | - $1 = (unsigned char *)malloc(len + 1); |
2301 | - if ($1 == 0) { |
2302 | - std::cerr << "out of memory\n"; |
2303 | - return 0; |
2304 | - } |
2305 | - JCALL4(GetByteArrayRegion, jenv, $input, 0, len, (jbyte *)$1); |
2306 | -} |
2307 | - |
2308 | -%typemap(freearg) unsigned char* %{ |
2309 | - free($1); |
2310 | -%} |
2311 | - |
2312 | -// change Java wrapper output mapping for unsigned char* |
2313 | -%typemap(javaout) unsigned char* { |
2314 | - return $jnicall; |
2315 | - } |
2316 | - |
2317 | -%typemap(javain) unsigned char* "$javainput" |
2318 | - |
2319 | - |
2320 | -struct FindResult { |
2321 | - int x, y; |
2322 | - int w, h; |
2323 | - double score; |
2324 | - FindResult(){ |
2325 | - x=0;y=0;w=0;h=0;score=-1;text = ""; |
2326 | - } |
2327 | - FindResult(int _x, int _y, int _w, int _h, double _score){ |
2328 | - x = _x; y = _y; |
2329 | - w = _w; h = _h; |
2330 | - score = _score; |
2331 | - text = ""; |
2332 | - } |
2333 | - |
2334 | - std::string text; |
2335 | -}; |
2336 | - |
2337 | -class OCRRect { |
2338 | - |
2339 | -public: |
2340 | - |
2341 | - OCRRect(); |
2342 | - OCRRect(int x_, int y_, int width_, int height_); |
2343 | - |
2344 | - int x; |
2345 | - int y; |
2346 | - int height; |
2347 | - int width; |
2348 | - |
2349 | -}; |
2350 | - |
2351 | -class OCRChar : public OCRRect{ |
2352 | - |
2353 | -public: |
2354 | - |
2355 | - OCRChar(const std::string& ch_, int x_, int y_, int width_, int height_) |
2356 | - : ch(ch_), OCRRect(x_,y_,width_,height_){}; |
2357 | - |
2358 | - std::string ch; |
2359 | -}; |
2360 | - |
2361 | -class OCRWord : public OCRRect { |
2362 | - |
2363 | -public: |
2364 | - float score; |
2365 | - std::string getString(); |
2366 | - |
2367 | - std::vector<OCRChar> getChars(); |
2368 | -}; |
2369 | - |
2370 | -class OCRLine : public OCRRect{ |
2371 | -public: |
2372 | - |
2373 | - std::string getString(); |
2374 | - std::vector<OCRWord> getWords(); |
2375 | - |
2376 | -}; |
2377 | - |
2378 | -class OCRParagraph : public OCRRect{ |
2379 | -public: |
2380 | - |
2381 | - std::vector<OCRLine> getLines(); |
2382 | - |
2383 | -}; |
2384 | - |
2385 | -class OCRText : public OCRRect{ |
2386 | - |
2387 | -public: |
2388 | - |
2389 | - std::string getString(); |
2390 | - |
2391 | - std::vector<OCRWord> getWords(); |
2392 | - std::vector<OCRParagraph> getParagraphs(); |
2393 | - |
2394 | -}; |
2395 | - |
2396 | -class Blob : public cv::Rect{ |
2397 | - |
2398 | -public: |
2399 | - |
2400 | - Blob(){}; |
2401 | - Blob(const cv::Rect& rect); |
2402 | - |
2403 | - bool isContainedBy(Blob& b); |
2404 | - |
2405 | - double area; |
2406 | - int mb; |
2407 | - int mg; |
2408 | - int mr; |
2409 | - int score; |
2410 | -}; |
2411 | - |
2412 | -%include "enumtypeunsafe.swg" |
2413 | -%javaconst(1); |
2414 | -enum TARGET_TYPE{ |
2415 | - IMAGE, |
2416 | - TEXT, |
2417 | - BUTTON |
2418 | -}; |
2419 | - |
2420 | -namespace sikuli { |
2421 | - |
2422 | - class FindInput{ |
2423 | - |
2424 | - public: |
2425 | - |
2426 | - FindInput(); |
2427 | - FindInput(cv::Mat source, cv::Mat target); |
2428 | - FindInput(cv::Mat source, int target_type, const char* target); |
2429 | - |
2430 | - FindInput(const char* source_filename, int target_type, const char* target); |
2431 | - |
2432 | - FindInput(cv::Mat source, int target_type); |
2433 | - FindInput(const char* source_filename, int target_type); |
2434 | - |
2435 | - // copy everything in 'other' except for the source image |
2436 | - FindInput(cv::Mat source, const FindInput other); |
2437 | - |
2438 | - void setSource(const char* source_filename); |
2439 | - void setTarget(int target_type, const char* target_string); |
2440 | - |
2441 | - void setSource(cv::Mat source); |
2442 | - void setTarget(cv::Mat target); |
2443 | - |
2444 | - cv::Mat getSourceMat(); |
2445 | - cv::Mat getTargetMat(); |
2446 | - |
2447 | - void setFindAll(bool all); |
2448 | - bool isFindingAll(); |
2449 | - |
2450 | - void setLimit(int limit); |
2451 | - int getLimit(); |
2452 | - |
2453 | - void setSimilarity(double similarity); |
2454 | - double getSimilarity(); |
2455 | - |
2456 | - int getTargetType(); |
2457 | - |
2458 | - std::string getTargetText(); |
2459 | - }; |
2460 | - |
2461 | - class Vision{ |
2462 | - public: |
2463 | - |
2464 | - static std::vector<FindResult> find(FindInput q); |
2465 | - static std::vector<FindResult> findChanges(FindInput q); |
2466 | - |
2467 | - static double compare(cv::Mat m1, cv::Mat m2); |
2468 | - |
2469 | - static void initOCR(const char* ocrDataPath); |
2470 | - |
2471 | - static std::string query(const char* index_filename, cv::Mat image); |
2472 | - |
2473 | - static OCRText recognize_as_ocrtext(cv::Mat image); |
2474 | - |
2475 | - static std::vector<FindResult> findBlobs(const cv::Mat& image, bool textOnly=false); |
2476 | - |
2477 | - static std::vector<FindResult> findTextBlobs(const cv::Mat& image); |
2478 | - |
2479 | - static std::string recognize(cv::Mat image); |
2480 | - static std::string recognizeWord(cv::Mat image); |
2481 | - |
2482 | - //helper functions |
2483 | - static cv::Mat createMat(int _rows, int _cols, unsigned char* _data); |
2484 | - |
2485 | - static void setParameter(std::string param, float val); |
2486 | - static float getParameter(std::string param); |
2487 | - |
2488 | - private: |
2489 | - |
2490 | - }; |
2491 | - |
2492 | - |
2493 | - enum DebugCategories { |
2494 | - OCR, FINDER |
2495 | - }; |
2496 | - void setDebug(DebugCategories cat, int level); |
2497 | - |
2498 | - |
2499 | - |
2500 | -} |
2501 | - |
2502 | -class OCR { |
2503 | -public: |
2504 | - static void setParameter(std::string param, std::string value); |
2505 | -}; |
2506 | - |
2507 | - |
2508 | -namespace cv{ |
2509 | - class Mat { |
2510 | - int _w, _h; |
2511 | - unsigned char* _data; |
2512 | - |
2513 | - public: |
2514 | - //Mat(int _rows, int _cols, int _type, unsigned char* _data); |
2515 | - }; |
2516 | - |
2517 | -} |
2518 | - |
2519 | - |
2520 | |
2521 | === removed directory '.pc/no-opencv-surf-module.patch' |
2522 | === removed directory '.pc/no-opencv-surf-module.patch/sikuli-script' |
2523 | === removed directory '.pc/no-opencv-surf-module.patch/sikuli-script/src' |
2524 | === removed directory '.pc/no-opencv-surf-module.patch/sikuli-script/src/main' |
2525 | === removed directory '.pc/no-opencv-surf-module.patch/sikuli-script/src/main/native' |
2526 | === removed file '.pc/no-opencv-surf-module.patch/sikuli-script/src/main/native/cvgui.cpp' |
2527 | --- .pc/no-opencv-surf-module.patch/sikuli-script/src/main/native/cvgui.cpp 2012-06-25 12:33:23 +0000 |
2528 | +++ .pc/no-opencv-surf-module.patch/sikuli-script/src/main/native/cvgui.cpp 1970-01-01 00:00:00 +0000 |
2529 | @@ -1,2508 +0,0 @@ |
2530 | -/* |
2531 | - * Copyright 2010-2011, Sikuli.org |
2532 | - * Released under the MIT License. |
2533 | - * |
2534 | - */ |
2535 | -#include "cvgui.h" |
2536 | -#include "sikuli-debug.h" |
2537 | -#include <iostream> |
2538 | -using namespace std; |
2539 | -using namespace sikuli; |
2540 | - |
2541 | - |
2542 | -Scalar Color::RED(0,0,255); |
2543 | -Scalar Color::WHITE(255,255,255); |
2544 | - |
2545 | -Scalar Color::RANDOM() { |
2546 | - return Scalar(rand()&255, rand()&255, rand()&255); |
2547 | -}; |
2548 | - |
2549 | -static bool sort_by_x (Rect a, Rect b){ |
2550 | - return (a.x < b.x); |
2551 | -} |
2552 | - |
2553 | -static bool sort_blob_by_x(Blob a, Blob b){ |
2554 | - return (a.x < b.x); |
2555 | -} |
2556 | - |
2557 | -static bool sort_blob_by_y(Blob a, Blob b){ |
2558 | - return (a.y < b.y); |
2559 | -} |
2560 | - |
2561 | -#define SHOW(x) namedWindow(#x,1); imshow(#x,x); |
2562 | -#define SHOW0(x) namedWindow(#x,1); imshow(#x,x); waitKey(0); |
2563 | - |
2564 | -//class VisualLogger{ |
2565 | -// |
2566 | -// |
2567 | -// int image_i; |
2568 | -// int step_i; |
2569 | -// char* prefix; |
2570 | -// |
2571 | -//public: |
2572 | -// |
2573 | -// VisualLogger(){ |
2574 | -// } |
2575 | -// |
2576 | -// static void newImage(){ |
2577 | -// image_i++; |
2578 | -// step_i = 0; |
2579 | -// } |
2580 | -// |
2581 | -// static void log(const char* name, const Mat& image){ |
2582 | -// char buf[200]; |
2583 | -// |
2584 | -// if (prefix){ |
2585 | -// |
2586 | -// sprintf(buf, "%s-%02d-%s.vlog.png", prefix, step_i, name); |
2587 | -// |
2588 | -// }else{ |
2589 | -// sprintf(buf, "%03d-%02d-%s.vlog.png",image_i,step_i,name); |
2590 | -// } |
2591 | -// |
2592 | -// imwrite(buf, image); |
2593 | -// |
2594 | -// step_i++; |
2595 | -// } |
2596 | -//}; |
2597 | -// |
2598 | -//static VisualLogger vlog; |
2599 | - |
2600 | -int VisualLogger::image_i = 0; |
2601 | -int VisualLogger::step_i = 0; |
2602 | -//bool VisualLogger::enabled = false; |
2603 | -char* VisualLogger::prefix = 0; |
2604 | - |
2605 | -//#define VLOG(x,y) |
2606 | - |
2607 | -void |
2608 | -Util::rgb2grayC3(const Mat& input, Mat& output){ |
2609 | - Mat g; |
2610 | - cvtColor(input, g, CV_RGB2GRAY); |
2611 | - Mat ss[3] = {g,g,g}; |
2612 | - merge(ss,3,output); |
2613 | -} |
2614 | - |
2615 | -void |
2616 | -Util::growRect(Rect& rect, int xd, int yd, Rect bounds){ |
2617 | - |
2618 | - |
2619 | - Rect in = rect; |
2620 | - in.x -= xd; |
2621 | - in.width += 2*xd; |
2622 | - in.y -= yd; |
2623 | - in.height += 2*yd; |
2624 | - |
2625 | - int x1 = max(bounds.x, in.x); |
2626 | - int y1 = max(bounds.y, in.y); |
2627 | - int x2 = min(in.x + in.width, bounds.width); |
2628 | - int y2 = min(in.y + in.height, bounds.height); |
2629 | - |
2630 | - if (x2 < x1 || y2 < y1) |
2631 | - rect = Rect(0,0,0,0); |
2632 | - else |
2633 | - rect = Rect(x1,y1,x2-x1+1,y2-y1+1); |
2634 | - |
2635 | -} |
2636 | - |
2637 | -void |
2638 | -Util::growRect(Rect& rect, int xd, int yd, cv::Mat image){ |
2639 | - growRect(rect, xd, yd, Rect(0,0, image.cols-1, image.rows-1)); |
2640 | -} |
2641 | - |
2642 | - |
2643 | - |
2644 | -void |
2645 | -Painter::drawRect(Mat& image, Rect r, Scalar color){ |
2646 | - rectangle(image, |
2647 | - Point(r.x, r.y), |
2648 | - Point(r.x + r.width, r.y + r.height), |
2649 | - color); |
2650 | -} |
2651 | - |
2652 | -void |
2653 | -Painter::drawRect(Mat& image, OCRRect r, Scalar color){ |
2654 | - rectangle(image, |
2655 | - Point(r.x, r.y), |
2656 | - Point(r.x + r.width, r.y + r.height), |
2657 | - color); |
2658 | -} |
2659 | - |
2660 | -void |
2661 | -Painter::drawRects(Mat& image, vector<Rect>& rects, Scalar color){ |
2662 | - for (vector<Rect>::iterator r = rects.begin(); |
2663 | - r != rects.end(); ++r){ |
2664 | - |
2665 | - rectangle(image, |
2666 | - Point(r->x, r->y), |
2667 | - Point(r->x + r->width, r->y + r->height), |
2668 | - color); |
2669 | - } |
2670 | -} |
2671 | - |
2672 | - |
2673 | - |
2674 | -void |
2675 | -Painter::drawBlobsRandomShading(Mat& image, vector<Blob>& blobs){ |
2676 | - |
2677 | - |
2678 | - Mat blank = image.clone(); |
2679 | - blank = 0.0; |
2680 | - |
2681 | - Mat shading = blank; |
2682 | - for (vector<Blob>::iterator it = blobs.begin(); |
2683 | - it != blobs.end(); ++it){ |
2684 | - Blob& box = *it; |
2685 | - rectangle(shading, Point(box.x,box.y), Point(box.x+box.width,box.y+box.height), Color::RANDOM(), CV_FILLED); |
2686 | - } |
2687 | - |
2688 | - image = image * 0.5 + shading * 0.7; |
2689 | - |
2690 | - Painter::drawBlobs(image, blobs, Color::WHITE); |
2691 | -} |
2692 | - |
2693 | -void |
2694 | -Painter::drawRects(Mat& image, vector<Rect>& rects){ |
2695 | - drawRects(image, rects, Scalar(0,0,255)); |
2696 | -} |
2697 | - |
2698 | -void |
2699 | -Painter::drawBlobs(Mat& image, vector<Blob>& blobs){ |
2700 | - for (vector<Blob>::iterator it = blobs.begin(); |
2701 | - it != blobs.end(); ++it){ |
2702 | - |
2703 | - Blob& blob = *it; |
2704 | - |
2705 | - Scalar color(blob.mr,blob.mg,blob.mb); |
2706 | - vector<Rect> rs; |
2707 | - rs.push_back(blob); |
2708 | - drawRects(image, rs, color); |
2709 | - } |
2710 | -} |
2711 | - |
2712 | -void |
2713 | -Painter::drawBlobs(Mat& image, vector<Blob>& blobs, Scalar color){ |
2714 | - vector<Rect> rs; |
2715 | - |
2716 | - for (vector<Blob>::iterator it = blobs.begin(); |
2717 | - it != blobs.end(); ++it){ |
2718 | - |
2719 | - Blob& blob = *it; |
2720 | - rs.push_back(blob); |
2721 | - } |
2722 | - drawRects(image, rs, color); |
2723 | -} |
2724 | - |
2725 | -void |
2726 | -Painter::drawLineBlobs(Mat& image, vector<LineBlob>& lineblobs, Scalar color){ |
2727 | - for (vector<LineBlob>::iterator it1 = lineblobs.begin(); |
2728 | - it1 != lineblobs.end(); ++it1){ |
2729 | - |
2730 | - LineBlob& lineblob = *it1; |
2731 | - |
2732 | - |
2733 | - if (lineblob.blobs.size()>=2){ |
2734 | - |
2735 | - for (vector<Blob>::iterator r = lineblob.blobs.begin() + 1; |
2736 | - r != lineblob.blobs.end(); ++r){ |
2737 | - |
2738 | - Rect previous = *(r-1); |
2739 | - Rect current = *r; |
2740 | - |
2741 | - Point from(previous.x+previous.width,previous.y); |
2742 | - Point to(current.x,current.y); |
2743 | - cv::line(image, from, to, Scalar(255,255,255)); |
2744 | - } |
2745 | - } |
2746 | - |
2747 | - drawRect(image, lineblob, color); |
2748 | - } |
2749 | -} |
2750 | - |
2751 | -void |
2752 | -Painter::drawParagraphBlobs(Mat& image, vector<ParagraphBlob> blobs, Scalar color){ |
2753 | - for (vector<ParagraphBlob>::iterator it = blobs.begin(); |
2754 | - it != blobs.end(); ++it){ |
2755 | - |
2756 | - ParagraphBlob& parablob = *it; |
2757 | - for (vector<LineBlob>::iterator it1 = parablob.lineblobs.begin(); |
2758 | - it1 != parablob.lineblobs.end(); ++it1){ |
2759 | - |
2760 | - LineBlob& lineblob = *it1; |
2761 | - drawRect(image, lineblob, Scalar(255,255,0)); |
2762 | - } |
2763 | - |
2764 | - drawRect(image, parablob, Scalar(0,0,255)); |
2765 | - |
2766 | - } |
2767 | -} |
2768 | - |
2769 | -void |
2770 | -Painter::drawOCRWord(Mat& ocr_result_image, OCRWord ocrword){ |
2771 | - |
2772 | - cout << ocrword.x << " " << ocrword.y << " " << ocrword.width << " " << ocrword.height << ": "; |
2773 | - cout << ocrword.getString() << endl; |
2774 | - |
2775 | - drawRect(ocr_result_image, ocrword, Scalar(255,255,0)); |
2776 | - Point pt(ocrword.x, ocrword.y + ocrword.height - 10); |
2777 | - putText(ocr_result_image, ocrword.getString(), pt, |
2778 | - FONT_HERSHEY_SIMPLEX, 0.4, Color::RED); |
2779 | - |
2780 | -} |
2781 | - |
2782 | -void |
2783 | -Painter::drawOCRLine(Mat& ocr_result_image, OCRLine ocrline){ |
2784 | - vector<OCRWord> ocrwords = ocrline.getWords(); |
2785 | - for (vector<OCRWord>::iterator it = ocrwords.begin(); it != ocrwords.end(); ++it){ |
2786 | - OCRWord& ocrword = *it; |
2787 | - drawOCRWord(ocr_result_image, ocrword); |
2788 | - } |
2789 | -} |
2790 | - |
2791 | -void |
2792 | -Painter::drawOCRParagraph(Mat& ocr_result_image, OCRParagraph ocrpara){ |
2793 | - vector<OCRLine> ocrlines = ocrpara.getLines(); |
2794 | - for (vector<OCRLine>::iterator it = ocrlines.begin(); it != ocrlines.end(); ++it){ |
2795 | - OCRLine& ocrline = *it; |
2796 | - drawOCRLine(ocr_result_image, ocrline); |
2797 | - } |
2798 | -} |
2799 | - |
2800 | -void |
2801 | -Painter::drawOCRText(Mat& ocr_result_image, OCRText ocrtext){ |
2802 | - vector<OCRParagraph> ocrparas = ocrtext.getParagraphs(); |
2803 | - for (vector<OCRParagraph>::iterator it = ocrparas.begin(); it != ocrparas.end(); ++it){ |
2804 | - OCRParagraph& ocrpara = *it; |
2805 | - drawOCRParagraph(ocr_result_image, ocrpara); |
2806 | - } |
2807 | -} |
2808 | - |
2809 | - |
2810 | - |
2811 | - |
2812 | -void |
2813 | -LineBlob::merge(LineBlob& blob){ |
2814 | - |
2815 | - for (vector<Blob>::iterator it = blob.blobs.begin(); |
2816 | - it != blob.blobs.end(); ++it){ |
2817 | - add(*it); |
2818 | - } |
2819 | - |
2820 | -} |
2821 | - |
2822 | -void |
2823 | -LineBlob::updateBoundingRect(Blob& blob){ |
2824 | - if (blobs.size() == 0){ |
2825 | - x = blob.x; |
2826 | - y = blob.y; |
2827 | - height = blob.height; |
2828 | - width = blob.width; |
2829 | - |
2830 | - }else{ |
2831 | - |
2832 | - int x1,y1,x2,y2; |
2833 | - x1 = min(x, blob.x); |
2834 | - y1 = min(y, blob.y); |
2835 | - x2 = max(x+width, blob.x + blob.width); |
2836 | - y2 = max(y+height, blob.y + blob.height); |
2837 | - |
2838 | - x = x1; |
2839 | - y = y1; |
2840 | - height = y2 - y1; |
2841 | - width = x2 - x1; |
2842 | - } |
2843 | -} |
2844 | - |
2845 | -void |
2846 | -LineBlob::add(Blob& blob){ |
2847 | - updateBoundingRect(blob); |
2848 | - blobs.push_back(blob); |
2849 | -} |
2850 | - |
2851 | -void |
2852 | -LineBlob::calculateBoundingRectangle(){ |
2853 | - int x1,y1,x2,y2; |
2854 | - Blob& first_blob = blobs.front(); |
2855 | - x1 = first_blob.x; |
2856 | - x2 = first_blob.x + first_blob.width; |
2857 | - y1 = first_blob.y; |
2858 | - y2 = first_blob.y + first_blob.height; |
2859 | - |
2860 | - for (vector<Blob>::iterator it_line = blobs.begin()+1; |
2861 | - it_line != blobs.end(); ++it_line){ |
2862 | - Blob& b = *it_line; |
2863 | - x1 = min(x1, b.x); |
2864 | - y1 = min(y1, b.y); |
2865 | - x2 = max(x2, b.x + b.width); |
2866 | - y2 = max(y2, b.y + b.height); |
2867 | - } |
2868 | - |
2869 | - x = x1; |
2870 | - y = y1; |
2871 | - height = y2 - y1; |
2872 | - width = x2 - x1; |
2873 | -} |
2874 | - |
2875 | -void |
2876 | -ParagraphBlob::add(LineBlob& blob){ |
2877 | - |
2878 | - if (lineblobs.size() == 0){ |
2879 | - x = blob.x; |
2880 | - y = blob.y; |
2881 | - height = blob.height; |
2882 | - width = blob.width; |
2883 | - |
2884 | - }else{ |
2885 | - |
2886 | - int x1,y1,x2,y2; |
2887 | - x1 = min(x, blob.x); |
2888 | - y1 = min(y, blob.y); |
2889 | - x2 = max(x+width, blob.x + blob.width); |
2890 | - y2 = max(y+height, blob.y + blob.height); |
2891 | - |
2892 | - x = x1; |
2893 | - y = y1; |
2894 | - height = y2 - y1; |
2895 | - width = x2 - x1; |
2896 | - } |
2897 | - lineblobs.push_back(blob); |
2898 | -} |
2899 | - |
2900 | - |
2901 | - |
2902 | -void denoise(Mat& src){ |
2903 | - |
2904 | - //src = src * 0.1; |
2905 | - |
2906 | - Mat kernel = Mat::ones(3,3,CV_32FC1); |
2907 | - kernel.at<float>(2,2) = 0; |
2908 | - |
2909 | - Mat srcF, destF; |
2910 | - src.convertTo(srcF, CV_32FC1, 0.1); |
2911 | - |
2912 | - filter2D(srcF, destF, -1, kernel); |
2913 | - |
2914 | - Mat destU; |
2915 | - destF.convertTo(destU, CV_8UC1); |
2916 | - |
2917 | - threshold(destU, destU, 60, 255, THRESH_BINARY); |
2918 | - |
2919 | - bitwise_and(src, destU, src); |
2920 | -} |
2921 | - |
2922 | - |
2923 | - |
2924 | - |
2925 | -void |
2926 | -cvgui::linkLineBlobsIntoPagagraphBlobs(vector<LineBlob>& blobs, vector<ParagraphBlob>& parablobs){ |
2927 | - |
2928 | - sort(blobs, sort_blob_by_y); |
2929 | - |
2930 | - for (vector<LineBlob>::iterator it = blobs.begin(); |
2931 | - it != blobs.end(); ++it){ |
2932 | - |
2933 | - LineBlob& blob = *it; |
2934 | - |
2935 | - vector<ParagraphBlob>::iterator it1; |
2936 | - for (it1 = parablobs.begin(); |
2937 | - it1 != parablobs.end(); ++it1){ |
2938 | - |
2939 | - ParagraphBlob& parablob = *it1; |
2940 | - |
2941 | - bool left_aligned = abs(parablob.x - blob.x) < 10; |
2942 | - bool small_vertical_spacing = abs(blob.y - (parablob.y + parablob.height)) < 15; |
2943 | - |
2944 | - bool same_paragraph = left_aligned & small_vertical_spacing; |
2945 | - |
2946 | - if (same_paragraph){ |
2947 | - parablob.add(blob); |
2948 | - break; |
2949 | - } |
2950 | - } |
2951 | - |
2952 | - if (it1 == parablobs.end()){ |
2953 | - ParagraphBlob new_parablob; |
2954 | - new_parablob.add(blob); |
2955 | - parablobs.push_back(new_parablob); |
2956 | - } |
2957 | - } |
2958 | -} |
2959 | - |
2960 | -void |
2961 | -cvgui::mergeLineBlobs(vector<LineBlob>& blobs, vector<LineBlob>& merged_blobs){ |
2962 | - |
2963 | - sort(blobs, sort_blob_by_x); |
2964 | - |
2965 | - for (vector<LineBlob>::iterator it = blobs.begin(); |
2966 | - it != blobs.end(); ++it){ |
2967 | - |
2968 | - LineBlob& blob = *it; |
2969 | - |
2970 | - vector<LineBlob>::iterator l; |
2971 | - for (l = merged_blobs.begin(); l != merged_blobs.end(); ++l){ |
2972 | - |
2973 | - LineBlob& merged_blob = *l; |
2974 | - |
2975 | - bool similar_baseline = abs((merged_blob.y + merged_blob.height) - (blob.y + blob.height)) < 5; |
2976 | - bool small_spacing = (blob.x - (merged_blob.x + merged_blob.width)) < 10; |
2977 | - |
2978 | - bool cond1 = merged_blob.isContainedBy(blob) || blob.isContainedBy(merged_blob); |
2979 | - |
2980 | - bool same_line = cond1 || (similar_baseline && small_spacing); |
2981 | - |
2982 | - if (same_line){ |
2983 | - merged_blob.merge(blob); |
2984 | - break; |
2985 | - } |
2986 | - } |
2987 | - |
2988 | - if (l == merged_blobs.end()){ |
2989 | - merged_blobs.push_back(blob); |
2990 | - } |
2991 | - |
2992 | - } |
2993 | -} |
2994 | - |
2995 | -void |
2996 | -cvgui::linkBlobsIntoLineBlobs(vector<Blob>& blobs, vector<LineBlob>& lines, int max_spacing){ |
2997 | - |
2998 | - |
2999 | - sort(blobs, sort_blob_by_x); |
3000 | - for (vector<Blob>::iterator it = blobs.begin(); |
3001 | - it != blobs.end(); ++it){ |
3002 | - |
3003 | - Blob& blob = *it; |
3004 | - |
3005 | - vector<LineBlob>::iterator l; |
3006 | - for (l = lines.begin(); l != lines.end(); ++l){ |
3007 | - |
3008 | - LineBlob& line = *l; |
3009 | - Blob& last = line.blobs.back(); |
3010 | - |
3011 | - bool similar_baseline = abs((last.y + last.height) - (blob.y + blob.height)) < 5; |
3012 | - bool similar_centerline = abs((last.y + last.height/2) - (blob.y + blob.height/2)) < 5; |
3013 | - bool similar_height = 1.0*min(last.height,blob.height)/max(last.height,blob.height) > 0.5; |
3014 | - bool similar_width = 1.0*min(last.width,blob.width)/max(last.width,blob.width) > 0.5; |
3015 | - |
3016 | - bool small_overlap = blob.x > ((last.x + last.width)-2); |
3017 | - |
3018 | - |
3019 | - bool small_spacing = (blob.x - (last.x + last.width)) < max_spacing; |
3020 | - |
3021 | - bool is_dot = blob.height < 3 && blob.width < 3 && similar_baseline && small_spacing; |
3022 | - |
3023 | - int th = 40; |
3024 | - bool similar_foreground_color = |
3025 | - abs(last.mr - blob.mr) < th && abs(last.mg - blob.mg) < th && abs(last.mb - blob.mb) < th; |
3026 | - |
3027 | - |
3028 | - //bool is_probably_i = blob.width < 2 || last.width < 2; |
3029 | - |
3030 | - |
3031 | - bool same_line = (similar_centerline || similar_baseline) |
3032 | - && similar_height |
3033 | - && small_overlap |
3034 | - //&& similar_width |
3035 | - && small_spacing |
3036 | - && similar_foreground_color; //|| is_probably_i); |
3037 | - |
3038 | - |
3039 | - bool very_close = (blob.x - (last.x + last.width)) < 3; |
3040 | - |
3041 | - // bool vertically_overlap = similar_baseline; |
3042 | - |
3043 | - if (same_line || (very_close && similar_height && similar_baseline)){ |
3044 | - line.add(blob); |
3045 | - break; |
3046 | - } |
3047 | - } |
3048 | - |
3049 | - if (l == lines.end()){ |
3050 | - |
3051 | - LineBlob newline; |
3052 | - newline.add(blob); |
3053 | - lines.push_back(newline); |
3054 | - } |
3055 | - |
3056 | - } |
3057 | -} |
3058 | - |
3059 | - |
3060 | -void |
3061 | -cvgui::run_ocr_on_lineblobs(vector<LineBlob>& ocr_input_lineblobs, |
3062 | - Mat& input_image, |
3063 | - vector<OCRLine>& ocrlines){ |
3064 | - |
3065 | - |
3066 | - for (vector<LineBlob>::iterator it = ocr_input_lineblobs.begin(); |
3067 | - it != ocr_input_lineblobs.end(); ++it){ |
3068 | - |
3069 | - LineBlob& lineblob = *it; |
3070 | - OCRLine ocrline; |
3071 | - OCRWord ocrword; |
3072 | - |
3073 | - // if (lineblob.blobs.size()<10) |
3074 | - // continue; |
3075 | - // |
3076 | - |
3077 | - |
3078 | - Mat wordImage(input_image,lineblob); |
3079 | - |
3080 | - Mat ocrImage; // the image passed to tesseract |
3081 | - bool upsampled = false; |
3082 | - if (wordImage.rows < 20){ |
3083 | - upsampled = true; |
3084 | - resize(wordImage, ocrImage, Size(wordImage.cols*2,wordImage.rows*2)); |
3085 | - }else { |
3086 | - ocrImage = wordImage.clone(); |
3087 | - } |
3088 | - |
3089 | - vector<OCRChar> ocr_chars; |
3090 | - ocr_chars = OCR::recognize((unsigned char*)ocrImage.data, |
3091 | - ocrImage.cols, |
3092 | - ocrImage.rows, |
3093 | - 8); |
3094 | - |
3095 | - for (vector<OCRChar>::iterator iter = ocr_chars.begin(); |
3096 | - iter != ocr_chars.end(); iter++){ |
3097 | - |
3098 | - |
3099 | - OCRChar& ocrchar = *iter; |
3100 | - |
3101 | - |
3102 | - if (upsampled){ |
3103 | - // scale back the coordinates in the OCR result |
3104 | - |
3105 | - ocrchar.x = ocrchar.x/2; |
3106 | - ocrchar.y = ocrchar.y/2; |
3107 | - ocrchar.width = ocrchar.width/2; |
3108 | - ocrchar.height = ocrchar.height/2; |
3109 | - } |
3110 | - |
3111 | - |
3112 | - ocrchar.x += lineblob.x; |
3113 | - ocrchar.y += lineblob.y; |
3114 | - |
3115 | - |
3116 | - |
3117 | - if (iter > ocr_chars.begin()){ |
3118 | - OCRChar& previous_ocrchar = *(iter-1); |
3119 | - |
3120 | - int spacing = ocrchar.x - (previous_ocrchar.x + previous_ocrchar.width); |
3121 | - //dout() << '[' << ocrchar.height << ':' << spacing << ']'; |
3122 | - //dout() << '[' << spacing << ']'; |
3123 | - |
3124 | - |
3125 | - if (lineblob.height > 6 && spacing >= 4){// || spacing >= 2){ |
3126 | - ocrline.addWord(ocrword); |
3127 | - ocrword.clear(); |
3128 | - //dout() << ' '; |
3129 | - } |
3130 | - } |
3131 | - |
3132 | - //dout() << ocrchar.ch; |
3133 | - |
3134 | - ocrword.add(ocrchar); |
3135 | - ocrword.y = lineblob.y; |
3136 | - ocrword.height = lineblob.height; |
3137 | - |
3138 | - |
3139 | - |
3140 | - |
3141 | - |
3142 | - } |
3143 | - |
3144 | - |
3145 | - ocrline.addWord(ocrword); |
3146 | - |
3147 | - //dout() << endl; |
3148 | - |
3149 | - |
3150 | - ocrlines.push_back(ocrline); |
3151 | - |
3152 | - } |
3153 | -} |
3154 | - |
3155 | -void getLeafBlobs(vector<Blob>& blobs, vector<Blob>& leaf_blobs){ |
3156 | - |
3157 | - leaf_blobs.clear(); |
3158 | - |
3159 | - for (vector<Blob>::iterator it = blobs.begin(); |
3160 | - it != blobs.end(); ++it){ |
3161 | - |
3162 | - Blob& a = *it; |
3163 | - |
3164 | - // check if blob 'a' contains any other blob |
3165 | - vector<Blob>::iterator it1; |
3166 | - for (it1 = blobs.begin(); |
3167 | - it1 != blobs.end(); ++it1){ |
3168 | - |
3169 | - Blob& b = *it1; |
3170 | - |
3171 | - if (it != it1 && b.isContainedBy(a)) |
3172 | - break; |
3173 | - } |
3174 | - |
3175 | - // if not, it is a leave blob |
3176 | - if (it1 == blobs.end()) |
3177 | - leaf_blobs.push_back(a); |
3178 | - |
3179 | - } |
3180 | -} |
3181 | - |
3182 | - |
3183 | -Mat |
3184 | -cvgui::findBoxesByVoting(const Mat& screen, |
3185 | - int bw, int bh, |
3186 | - vector<Blob>& output_blobs){ |
3187 | - |
3188 | - Mat dark; |
3189 | - Util::rgb2grayC3(screen,dark); |
3190 | - dark = dark * 0.5; |
3191 | - |
3192 | - |
3193 | - VLOG("Input", screen); |
3194 | - |
3195 | - Mat gray; |
3196 | - cvtColor(screen,gray,CV_RGB2GRAY); |
3197 | - |
3198 | - |
3199 | - // Code for experimenting differenty parameters for Canny |
3200 | - // for (int c=10;c<=100;c=c+10){ |
3201 | - // char buf[50]; |
3202 | - // Mat test; |
3203 | - // sprintf(buf,"Canny%d",c); |
3204 | - // Canny(gray,test,0.66*c,1.33*c,3,true); |
3205 | - // VLOG(buf, test); |
3206 | - // } |
3207 | - |
3208 | - Mat canny; |
3209 | - int s = 200; |
3210 | - Canny(gray,canny,0.66*s,1.33*s,3,true); |
3211 | - VLOG("Canny", canny); |
3212 | - |
3213 | - Mat edges; |
3214 | - Mat v = Mat::ones(2,2,CV_8UC1); |
3215 | - |
3216 | - dilate(canny, edges, v); |
3217 | - erode(edges, edges, v); |
3218 | - |
3219 | - dilate(edges, edges, Mat::ones(3,3,CV_8UC1)); |
3220 | - VLOG("Dilated", edges); |
3221 | - |
3222 | - double k = 0.85; |
3223 | - double tol = 0.10; |
3224 | - Mat q = Mat::ones(5,5,CV_8UC1); |
3225 | - |
3226 | - Mat h1,h2,hvotes; |
3227 | - voteCenter_Horizontal(edges, h1, bw*k, bw*tol, bh/2); |
3228 | - dilate(h1, h1, q); |
3229 | - voteCenter_Horizontal(edges, h2, bw*k, bw*tol, -bh/2); |
3230 | - dilate(h2, h2, q); |
3231 | - |
3232 | - bitwise_and(h1,h2,hvotes); |
3233 | - VLOG("H-votes", hvotes); |
3234 | - |
3235 | - |
3236 | - Mat v1,v2,vvotes; |
3237 | - voteCenter_Vertical(edges, v1, bh*k, bh*tol, bw/2); |
3238 | - dilate(v1, v1, q); |
3239 | - |
3240 | - voteCenter_Vertical(edges, v2, bh*k, bh*tol, -bw/2); |
3241 | - dilate(v2, v2, q); |
3242 | - |
3243 | - bitwise_and(v1,v2,vvotes); |
3244 | - VLOG("V-votes", vvotes); |
3245 | - |
3246 | - Mat hvvotes; |
3247 | - bitwise_and(vvotes,hvotes,hvvotes); |
3248 | - VLOG("HV-votes", hvvotes); |
3249 | - |
3250 | - |
3251 | - |
3252 | - |
3253 | - Mat copy = hvvotes.clone(); |
3254 | - |
3255 | - |
3256 | - vector<vector<Point> > contours; |
3257 | - vector<Vec4i> hierarchy; |
3258 | - |
3259 | - findContours( copy, contours, hierarchy, |
3260 | - CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE ); |
3261 | - |
3262 | - vector<Blob> blobs; |
3263 | - |
3264 | - Mat blank = dark.clone(); |
3265 | - blank = 0.0; |
3266 | - |
3267 | - Mat contour_shading = blank; |
3268 | - |
3269 | - |
3270 | - // define a perfect box for back-proj verification |
3271 | - Mat pbox = Mat::zeros(bh,bw,CV_8UC1); |
3272 | - pbox.row(0).setTo(255); |
3273 | - pbox.row(bh-1).setTo(255); |
3274 | - pbox.col(0).setTo(255); |
3275 | - pbox.col(bw-1).setTo(255); |
3276 | - int pscore = countNonZero(pbox); |
3277 | - |
3278 | - for (vector<vector<Point> >::iterator it = contours.begin(); |
3279 | - it != contours.end(); ++it){ |
3280 | - |
3281 | - vector<Point>& contour = *it; |
3282 | - |
3283 | - Rect r = boundingRect(Mat(contour)); |
3284 | - |
3285 | - double a1 = contourArea(Mat(contour)); |
3286 | - double a2 = r.height * r.width; |
3287 | - |
3288 | - int cx = r.x + r.width/2; |
3289 | - int cy = r.y + r.height/2; |
3290 | - |
3291 | - |
3292 | - Rect box(cx-bw/2,cy-bh/2,bw,bh); |
3293 | - |
3294 | - Mat e(edges, box); |
3295 | - // calculate the score by comparing each hypothesized box to the ideal box |
3296 | - Mat sc; |
3297 | - bitwise_and(e,pbox,sc); |
3298 | - int score = countNonZero(sc); |
3299 | - |
3300 | - // ignore those boxes with fewer than this percentage |
3301 | - // of edge pixels |
3302 | - if ((1.0 * score) / (1.0 * pscore) < 0.90) |
3303 | - continue; |
3304 | - |
3305 | - // rectangle(contour_shading, Point(box.x,box.y), Point(box.x+box.width,box.y+box.height), Color::RANDOM(), CV_FILLED); |
3306 | - |
3307 | - |
3308 | - Blob blob(box); |
3309 | - blob.score = score; |
3310 | - blobs.push_back(blob); |
3311 | - |
3312 | - } |
3313 | - |
3314 | - |
3315 | - Mat blobs_image = dark.clone(); |
3316 | - |
3317 | - Painter::drawBlobsRandomShading(blobs_image, blobs); |
3318 | - VLOG("BlobHypotheses", blobs_image); |
3319 | - |
3320 | - |
3321 | - // remove overlapping blobs |
3322 | - // and do non-maximal suppression |
3323 | - vector<Blob> nonoverlapping_blobs; |
3324 | - |
3325 | - for (vector<Blob>::iterator it = blobs.begin(); |
3326 | - it != blobs.end(); ++it){ |
3327 | - |
3328 | - Blob& b = *it; |
3329 | - |
3330 | - bool not_overlap = true; |
3331 | - int tolerance = 3; |
3332 | - vector<Blob>::iterator ito; |
3333 | - for (ito = nonoverlapping_blobs.begin(); |
3334 | - ito != nonoverlapping_blobs.end(); ++ito){ |
3335 | - |
3336 | - Blob& bo = *ito; |
3337 | - |
3338 | - not_overlap = b.x >= bo.x + bo.width - tolerance || b.y >= bo.y + bo.height - tolerance|| |
3339 | - b.x + b.width <= bo.x + tolerance|| b.y + b.height <= bo.y + tolerance; |
3340 | - |
3341 | - if (!not_overlap) |
3342 | - break; |
3343 | - |
3344 | - } |
3345 | - |
3346 | - if (not_overlap){ |
3347 | - |
3348 | - nonoverlapping_blobs.push_back(b); |
3349 | - |
3350 | - }else{ |
3351 | - // replace it if the score is better |
3352 | - |
3353 | - if (it->score > ito->score){ |
3354 | - |
3355 | - (*ito) = (*it); |
3356 | - } |
3357 | - |
3358 | - } |
3359 | - |
3360 | - } |
3361 | - |
3362 | - |
3363 | - vector<Blob>& result_blobs = nonoverlapping_blobs; |
3364 | - |
3365 | - |
3366 | - Mat result_blobs_image = dark.clone(); |
3367 | - Painter::drawBlobsRandomShading(result_blobs_image, result_blobs); |
3368 | - VLOG("OutputBlobs", result_blobs_image); |
3369 | - |
3370 | - // print output to stdout |
3371 | - for (vector<Blob>::iterator it = result_blobs.begin(); |
3372 | - it != result_blobs.end(); ++it){ |
3373 | - Blob& b = *it; |
3374 | - dout() << b.x << " " << b.y << " " << b.width << " " << b.height << " " << b.score << endl; |
3375 | - } |
3376 | - |
3377 | - |
3378 | - return result_blobs_image; |
3379 | -} |
3380 | - |
3381 | -Mat |
3382 | -cvgui::findPokerBoxes(const Mat& screen, vector<Blob>& output_blobs){ |
3383 | - |
3384 | - |
3385 | - //return findBoxesByVoting(screen, 70, 90, output_blobs); |
3386 | - return findBoxesByVoting(screen, 40, 50, output_blobs); |
3387 | - |
3388 | - |
3389 | -// old algorithm |
3390 | -#if 0 |
3391 | - Mat dark; |
3392 | - Util::rgb2grayC3(screen,dark); |
3393 | - dark = dark * 0.5; |
3394 | - |
3395 | - |
3396 | - VLOG("Input", screen); |
3397 | - |
3398 | - Mat gray; |
3399 | - cvtColor(screen,gray,CV_RGB2GRAY); |
3400 | - |
3401 | - //medianBlur(gray, gray, 3); |
3402 | - //VLOG("Blurred", gray); |
3403 | - |
3404 | - Mat edges; |
3405 | - |
3406 | - // Code for experimenting differenty parameters for Canny |
3407 | - // for (int c=10;c<=100;c=c+10){ |
3408 | - // char buf[50]; |
3409 | - // Mat test; |
3410 | - // sprintf(buf,"Canny%d",c); |
3411 | - // Canny(gray,test,0.66*c,1.33*c,3,true); |
3412 | - // VLOG(buf, test); |
3413 | - // } |
3414 | - |
3415 | - int s = 100; |
3416 | - Canny(gray,edges,0.66*s,1.33*s,3,true); |
3417 | - VLOG("Canny", edges); |
3418 | - |
3419 | - |
3420 | - Mat v = Mat::ones(2,2,CV_8UC1); |
3421 | - |
3422 | - dilate(edges, edges, v); |
3423 | - erode(edges, edges, v); |
3424 | - |
3425 | - VLOG("Dilated", edges); |
3426 | - |
3427 | - // experimental |
3428 | - Mat hlines,vlines; |
3429 | - dilate(edges, edges, Mat::ones(3,2,CV_8UC1)); |
3430 | - |
3431 | - |
3432 | - findLongLines_Vertical(edges,vlines, 50, 2); |
3433 | - VLOG("V-lines", vlines); |
3434 | - |
3435 | - findLongLines_Horizontal(edges,hlines, 50, 2); |
3436 | - VLOG("H-lines", hlines); |
3437 | - |
3438 | - |
3439 | - int bw = 70; |
3440 | - int bh = 20; |
3441 | - double k = 0.90; |
3442 | - |
3443 | - Mat q = Mat::ones(5,5,CV_8UC1); |
3444 | - |
3445 | - Mat h1,h2,hvotes; |
3446 | - voteCenter_Horizontal(edges, h1, bw*k, 2, bh/2); |
3447 | - dilate(h1, h1, q); |
3448 | - voteCenter_Horizontal(edges, h2, bw*k, 2, -bh/2); |
3449 | - dilate(h2, h2, q); |
3450 | - |
3451 | - bitwise_and(h1,h2,hvotes); |
3452 | - VLOG("H-votes", hvotes); |
3453 | - |
3454 | - |
3455 | - Mat v1,v2,vvotes; |
3456 | - voteCenter_Vertical(edges, v1, bh*k, 2, bw/2); |
3457 | - dilate(v1, v1, q); |
3458 | - |
3459 | - voteCenter_Vertical(edges, v2, bh*k, 2, -bw/2); |
3460 | - dilate(v2, v2, q); |
3461 | - |
3462 | - bitwise_and(v1,v2,vvotes); |
3463 | - VLOG("V-votes", vvotes); |
3464 | - |
3465 | - Mat hvvotes; |
3466 | - bitwise_and(vvotes,hvotes,hvvotes); |
3467 | - VLOG("HV-votes", hvvotes); |
3468 | - |
3469 | - |
3470 | -// Mat hvlines; |
3471 | -// bitwise_or(hlines, vlines, hvlines); |
3472 | -// VLOG("HV-lines", hvlines); |
3473 | - |
3474 | - // |
3475 | - |
3476 | - Mat lines; |
3477 | - findLongLines(edges, lines, 15); |
3478 | - |
3479 | - Mat w = Mat::ones(5,5,CV_8UC1); |
3480 | - dilate(lines, lines, w); |
3481 | - erode(lines, lines, w); |
3482 | - |
3483 | - VLOG("Lines", lines); |
3484 | - |
3485 | - |
3486 | - Mat lines2; |
3487 | - Mat z = Mat::ones(2,2,CV_8UC1); |
3488 | - |
3489 | - dilate(lines, lines, z); |
3490 | - |
3491 | - findLongLines(lines, lines2, 30, 15); |
3492 | - |
3493 | - //dilate(lines2, lines2, z); |
3494 | - //erode(lines2, lines2, z); |
3495 | - |
3496 | - VLOG("Lines2", lines2); |
3497 | - |
3498 | - |
3499 | - |
3500 | - Mat result = dark.clone(); |
3501 | - //Mat copy = edges.clone(); |
3502 | - //Mat copy = lines.clone(); |
3503 | - |
3504 | - Mat copy = lines2.clone(); |
3505 | - |
3506 | - |
3507 | - vector<vector<Point> > contours; |
3508 | - vector<Vec4i> hierarchy; |
3509 | - |
3510 | - findContours( copy, contours, hierarchy, |
3511 | - CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE ); |
3512 | - |
3513 | - vector<Blob> blobs; |
3514 | - |
3515 | - Mat blank = dark.clone(); |
3516 | - blank = 0.0; |
3517 | - |
3518 | - Mat contour_shading = blank;//dark.clone(); |
3519 | - |
3520 | - for (vector<vector<Point> >::iterator it = contours.begin(); |
3521 | - it != contours.end(); ++it){ |
3522 | - |
3523 | - vector<Point>& contour = *it; |
3524 | - |
3525 | - Rect r = boundingRect(Mat(contour)); |
3526 | - |
3527 | - double a1 = contourArea(Mat(contour)); |
3528 | - double a2 = r.height * r.width; |
3529 | - |
3530 | - |
3531 | - if (a2 < 100) |
3532 | - continue; |
3533 | - |
3534 | - |
3535 | - if (abs(r.width - 65) > 5) |
3536 | - continue; |
3537 | - |
3538 | - //if ( min(a1,a2)/max(a1,a2) > 0.80){ |
3539 | - |
3540 | - vector<vector<Point> > cs; |
3541 | - cs.push_back(contour); |
3542 | - drawContours(contour_shading, cs, -1, Color::RANDOM(), CV_FILLED); |
3543 | - |
3544 | - |
3545 | - Blob blob(r); |
3546 | - blobs.push_back(blob); |
3547 | - //} |
3548 | - |
3549 | - } |
3550 | - |
3551 | - Mat contours_image = contour_shading*0.7 + dark*0.5; |
3552 | - |
3553 | - Painter::drawBlobs(contours_image, blobs, Color::WHITE); |
3554 | - |
3555 | - VLOG("ColoredSelectedContours", contours_image); |
3556 | - |
3557 | - |
3558 | - |
3559 | - |
3560 | - vector<Blob> nonoverlapping_blobs; |
3561 | - |
3562 | - // print output to stdout |
3563 | - for (vector<Blob>::iterator it = blobs.begin(); |
3564 | - it != blobs.end(); ++it){ |
3565 | - |
3566 | - Blob& b = *it; |
3567 | - bool not_overlap = true; |
3568 | - for (vector<Blob>::iterator ito = nonoverlapping_blobs.begin(); |
3569 | - ito != nonoverlapping_blobs.end(); ++ito){ |
3570 | - |
3571 | - Blob& bo = *ito; |
3572 | - |
3573 | - not_overlap = b.x >= bo.x + bo.width || b.y >= bo.y + bo.height || |
3574 | - b.x + b.width <= bo.x || b.y + b.height <= bo.y; |
3575 | - |
3576 | - if (!not_overlap) |
3577 | - break; |
3578 | - |
3579 | - } |
3580 | - |
3581 | - if (not_overlap){ |
3582 | - nonoverlapping_blobs.push_back(b); |
3583 | - } |
3584 | - |
3585 | - } |
3586 | - |
3587 | - |
3588 | - vector<Blob>& result_blobs = nonoverlapping_blobs |
3589 | - |
3590 | - |
3591 | - Mat blobs_result = dark.clone(); |
3592 | - Painter::drawBlobs(blobs_result, result_blobs, Color::RED); |
3593 | - |
3594 | - VLOG("OutputBlobs", blobs_result); |
3595 | - |
3596 | - // print output to stdout |
3597 | - for (vector<Blob>::iterator it = result_blobs.begin(); |
3598 | - it != result_blobs.end(); ++it){ |
3599 | - |
3600 | - dout() << b.x << " " << b.y << " " << b.width << " " << b.height << endl; |
3601 | - } |
3602 | - |
3603 | - |
3604 | - return contours_image; |
3605 | -#endif |
3606 | -} |
3607 | - |
3608 | -void |
3609 | -cvgui::findBoxes(const Mat& screen, vector<Blob>& output_blobs){ |
3610 | - |
3611 | - Mat dark; |
3612 | - Util::rgb2grayC3(screen,dark); |
3613 | - dark = dark * 0.5; |
3614 | - |
3615 | - |
3616 | - VLOG("Input", screen); |
3617 | - |
3618 | - Mat gray; |
3619 | - cvtColor(screen,gray,CV_RGB2GRAY); |
3620 | - |
3621 | - //medianBlur(gray, gray, 3); |
3622 | - //VLOG("Blurred", gray); |
3623 | - |
3624 | - Mat edges; |
3625 | - |
3626 | -// Code for experimenting differenty parameters for Canny |
3627 | -// for (int c=10;c<=100;c=c+10){ |
3628 | -// char buf[50]; |
3629 | -// Mat test; |
3630 | -// sprintf(buf,"Canny%d",c); |
3631 | -// Canny(gray,test,0.66*c,1.33*c,3,true); |
3632 | -// VLOG(buf, test); |
3633 | -// } |
3634 | - |
3635 | - int s = 100; |
3636 | - Canny(gray,edges,0.66*s,1.33*s,3,true); |
3637 | - VLOG("Canny", edges); |
3638 | - |
3639 | - |
3640 | - dilate(edges, edges, Mat::ones(2,2,CV_8UC1)); |
3641 | - VLOG("Dilated", edges); |
3642 | - |
3643 | - |
3644 | - |
3645 | - |
3646 | - Mat result = dark.clone(); |
3647 | - Mat copy = edges.clone(); |
3648 | - |
3649 | - |
3650 | - vector<vector<Point> > contours; |
3651 | - vector<Vec4i> hierarchy; |
3652 | - |
3653 | - findContours( copy, contours, hierarchy, |
3654 | - CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE ); |
3655 | - |
3656 | -// findContours(edges, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); |
3657 | - |
3658 | - //findContours( copy, contours, hierarchy, |
3659 | - // CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE ); |
3660 | - |
3661 | -// cout << contours.size() << " " << hierarchy.size() << endl; |
3662 | - // iterate through all the top-level contours, |
3663 | - // draw each connected component with its own random color |
3664 | -// int idx = 0; |
3665 | -// for( ; idx >= 0; idx = hierarchy[idx][0]){ |
3666 | -// |
3667 | -// vector<Point>& contour = contours[idx]; |
3668 | -// |
3669 | -// |
3670 | -// //Scalar color( rand()&255, rand()&255, rand()&255 ); |
3671 | -// Scalar cyan(255,255,0); |
3672 | -// vector<vector<Point> > cs; |
3673 | -// cs.push_back(contour); |
3674 | -// drawContours( result, cs, -1, cyan, 2);//, CV_FILLED); |
3675 | -// |
3676 | -// // drawContours( result, contours, idx, color, CV_FILLED, 8, hierarchy ); |
3677 | -// |
3678 | -// } |
3679 | - |
3680 | - vector<Blob> blobs; |
3681 | - |
3682 | - |
3683 | - Mat box_contour_image = dark.clone(); |
3684 | - |
3685 | - for (vector<vector<Point> >::iterator it = contours.begin(); |
3686 | - it != contours.end(); ++it){ |
3687 | - |
3688 | - vector<Point>& contour = *it; |
3689 | - |
3690 | - Rect r = boundingRect(Mat(contour)); |
3691 | - |
3692 | - double a1 = contourArea(Mat(contour)); |
3693 | - double a2 = r.height * r.width; |
3694 | - |
3695 | - |
3696 | - |
3697 | - |
3698 | - if ( min(a1,a2)/max(a1,a2) > 0.80){ |
3699 | - |
3700 | - vector<vector<Point> > cs; |
3701 | - cs.push_back(contour); |
3702 | - drawContours(box_contour_image, cs, -1, Color::RANDOM(), 2);//, CV_FILLED); |
3703 | - |
3704 | - |
3705 | - Blob blob(r); |
3706 | - blobs.push_back(blob); |
3707 | - } |
3708 | - |
3709 | - } |
3710 | - |
3711 | - |
3712 | - VLOG("Box-shaped contours", box_contour_image); |
3713 | - |
3714 | - |
3715 | - Mat blobs_result = dark.clone(); |
3716 | - Painter::drawBlobs(blobs_result, blobs, Color::RED); |
3717 | - |
3718 | - VLOG("Blobs", blobs_result); |
3719 | - |
3720 | - |
3721 | - vector<Blob> unique_blobs; |
3722 | - for (vector<Blob>::iterator it = blobs.begin(); |
3723 | - it != blobs.end(); ++it){ |
3724 | - |
3725 | - Blob& a = *it; |
3726 | - |
3727 | - |
3728 | - vector<Blob>::iterator it1; |
3729 | - for (it1 = unique_blobs.begin(); |
3730 | - it1 != unique_blobs.end(); ++it1){ |
3731 | - |
3732 | - Blob& b = *it1; |
3733 | - |
3734 | - int d = 5; |
3735 | - bool similar_bounding_box = |
3736 | - abs(a.x-b.x) < d && abs(a.y-b.y) < d && |
3737 | - abs(a.height-b.height) < 2*d && |
3738 | - abs(a.width-b.width) < 2*d; |
3739 | - |
3740 | - |
3741 | - if (similar_bounding_box) |
3742 | - break; |
3743 | - |
3744 | - } |
3745 | - |
3746 | - // if no blob whose bounding box is similar |
3747 | - if (it1 == unique_blobs.end()){ |
3748 | - |
3749 | - // add this blob to the list of unique blobs |
3750 | - unique_blobs.push_back(a); |
3751 | - } |
3752 | - } |
3753 | - |
3754 | - Mat unique_blobs_result = dark.clone(); |
3755 | - Painter::drawBlobs(unique_blobs_result, unique_blobs, Color::RED); |
3756 | - |
3757 | - VLOG("UniqueBlobs", unique_blobs_result); |
3758 | - |
3759 | - |
3760 | - vector<Blob> leaf_blobs; |
3761 | - getLeafBlobs(unique_blobs, leaf_blobs); |
3762 | - |
3763 | - |
3764 | - Mat leaf_blobs_result = dark.clone(); |
3765 | - Painter::drawBlobs(leaf_blobs_result, leaf_blobs, Color::RED); |
3766 | - VLOG("LeafBlobs", leaf_blobs_result); |
3767 | - |
3768 | - output_blobs = leaf_blobs; |
3769 | -} |
3770 | - |
3771 | - |
3772 | - |
3773 | - |
3774 | -void |
3775 | -cvgui::computeUnitBlobs(const Mat& screen, Mat& output){ |
3776 | - |
3777 | - VLOG("Input", screen); |
3778 | - |
3779 | - Mat gray; |
3780 | - cvtColor(screen,gray,CV_RGB2GRAY); |
3781 | - |
3782 | - |
3783 | - Mat edges; |
3784 | - Canny(gray,edges,0.66*50,1.33*50,3,true); |
3785 | - VLOG("Canny", edges); |
3786 | - |
3787 | -// Mat corners; |
3788 | -// cornerHarris(gray,corners,10,5,1.0); |
3789 | - |
3790 | -// Mat corners_result = screen.clone(); |
3791 | -// vector<Point2f> corners; |
3792 | -// goodFeaturesToTrack(gray, corners, 50, 0.5, 10); |
3793 | -// for (vector<Point2f>::iterator it = corners.begin(); it != corners.end(); ++it){ |
3794 | -// Point2f& p = *it; |
3795 | -// circle(corners_result, p, 3, Scalar(0,0,255)); |
3796 | -// } |
3797 | -// VLOG("Corners", corners_result); |
3798 | - |
3799 | - |
3800 | - adaptiveThreshold(gray, gray, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY_INV, 5, 1); |
3801 | - VLOG("AdaptiveThresholded", gray); |
3802 | - |
3803 | - Mat lines; |
3804 | - cvgui::findLongLines(gray, lines); |
3805 | - |
3806 | - Mat lines_viz = lines.clone(); |
3807 | - dilate(lines_viz, lines_viz, Mat::ones(4,4,CV_8UC1)); |
3808 | - VLOG("LongLinesFound", lines_viz); |
3809 | - |
3810 | - Mat not_lines; |
3811 | - bitwise_not(lines, not_lines); |
3812 | - |
3813 | - Mat foreground; |
3814 | - bitwise_and(gray, not_lines, foreground); |
3815 | - |
3816 | - gray.setTo(0, lines); |
3817 | - VLOG("LongLinesRemoved",gray); |
3818 | - |
3819 | - |
3820 | - dilate(edges, edges, Mat::ones(3,3,CV_8UC1)); |
3821 | - bitwise_and(gray, edges, gray); |
3822 | - |
3823 | - VLOG("NonEdgeRemoved", gray); |
3824 | - |
3825 | - //GaussianBlur(gray, gray, Size(3, 3), 3); |
3826 | - //VLOG("Blurred", gray); |
3827 | - |
3828 | - output = gray; |
3829 | -} |
3830 | - |
3831 | - |
3832 | - |
3833 | -void |
3834 | -cvgui::getParagraphBlobs(const Mat& screen, vector<ParagraphBlob>& output_parablobs){ |
3835 | - |
3836 | - VisualLogger::newImage(); |
3837 | - Mat screen_gray; |
3838 | - cvtColor(screen,screen_gray,CV_RGB2GRAY); |
3839 | - |
3840 | - Mat blobs_mask; |
3841 | - cvgui::computeUnitBlobs(screen, blobs_mask); |
3842 | - |
3843 | - Mat dark; |
3844 | - Util::rgb2grayC3(screen,dark); |
3845 | - dark = dark * 0.5; |
3846 | - |
3847 | - vector<Blob> blobs; |
3848 | - cvgui::extractBlobs(blobs_mask, blobs); |
3849 | - |
3850 | - cvgui::calculateColor(blobs, screen, blobs_mask); |
3851 | - |
3852 | - // draw blobs |
3853 | - Mat result_blobs = dark.clone(); |
3854 | - Painter::drawBlobs(result_blobs, blobs, Scalar(255,255,0)); |
3855 | - VLOG("blobs-extracted",result_blobs); |
3856 | - |
3857 | - |
3858 | - vector<Blob> filtered_blobs; |
3859 | - for (vector<Blob>::iterator it = blobs.begin(); |
3860 | - it != blobs.end(); ++it){ |
3861 | - |
3862 | - Blob& blob = *it; |
3863 | - |
3864 | - // if (blob.height < 3 && blob.width < 3) |
3865 | - // continue; |
3866 | - // |
3867 | - // if (blob.height < 4) |
3868 | - // continue; |
3869 | - |
3870 | - filtered_blobs.push_back(blob); |
3871 | - } |
3872 | - |
3873 | - Mat result_filtered_blobs = dark.clone(); |
3874 | - Painter::drawBlobs(result_filtered_blobs, filtered_blobs, Scalar(255,255,0)); |
3875 | - |
3876 | - VLOG("blobs-filtered",result_filtered_blobs); |
3877 | - |
3878 | - |
3879 | - Mat result_lineblobs = dark.clone(); |
3880 | - |
3881 | - vector<LineBlob> lineblobs; |
3882 | - cvgui::linkBlobsIntoLineBlobs(filtered_blobs, lineblobs, 20); |
3883 | - |
3884 | - Painter::drawLineBlobs(result_lineblobs, lineblobs, Scalar(255,255,0)); |
3885 | - VLOG("lineblobs", result_lineblobs); |
3886 | - |
3887 | - |
3888 | - Mat result_lineblobs_filtered = dark.clone(); |
3889 | - vector<LineBlob> filtered_lineblobs; |
3890 | - |
3891 | - // Calculate the bounding rectangle of each line of linked blobs |
3892 | - for (vector<LineBlob>::iterator it_lines = lineblobs.begin(); |
3893 | - it_lines != lineblobs.end(); ++ it_lines){ |
3894 | - |
3895 | - LineBlob& line = *it_lines; |
3896 | - |
3897 | - // Ignore lines with fewer than X elements |
3898 | - if (line.blobs.size()<2) |
3899 | - continue; |
3900 | - |
3901 | - |
3902 | - if (line.height < 3) |
3903 | - continue; |
3904 | - |
3905 | - filtered_lineblobs.push_back(line); |
3906 | - } |
3907 | - |
3908 | - |
3909 | - |
3910 | - Painter::drawLineBlobs(result_lineblobs_filtered, filtered_lineblobs, Scalar(255,255,0)); |
3911 | - VLOG("lineblobs-filtered", result_lineblobs_filtered); |
3912 | - |
3913 | - |
3914 | - Mat result_merged_blobs = dark.clone(); |
3915 | - |
3916 | - vector<LineBlob> merged_lineblobs; |
3917 | - cvgui::mergeLineBlobs(filtered_lineblobs, merged_lineblobs); |
3918 | - Painter::drawLineBlobs(result_merged_blobs, merged_lineblobs, Scalar(255,255,0)); |
3919 | - VLOG("lineblobs-merged", result_merged_blobs); |
3920 | - |
3921 | - |
3922 | - vector<ParagraphBlob> parablobs; |
3923 | - cvgui::linkLineBlobsIntoPagagraphBlobs(merged_lineblobs, parablobs); |
3924 | - |
3925 | - Mat result_linked_parablobs = dark.clone(); |
3926 | - |
3927 | - Painter::drawParagraphBlobs(result_linked_parablobs, parablobs, Scalar(255,0,0)); |
3928 | - |
3929 | - VLOG("paragblobs", result_linked_parablobs); |
3930 | - |
3931 | - |
3932 | - output_parablobs = parablobs; |
3933 | - |
3934 | - |
3935 | -// Mat screen_dark = screen * 0.2; |
3936 | -// Mat ocr_result_image = screen_dark; |
3937 | -// |
3938 | -// |
3939 | -// for (vector<ParagraphBlob>::iterator it = parablobs.begin(); |
3940 | -// it != parablobs.end(); ++it){ |
3941 | -// |
3942 | -// |
3943 | -// ParagraphBlob& parablob = *it; |
3944 | -// |
3945 | -// vector<OCRLine> ocrlines; |
3946 | -// |
3947 | -// cvgui::run_ocr_on_lineblobs(parablob.lineblobs, screen_gray, ocrlines); |
3948 | -// |
3949 | -// Painter::drawOCRLines(ocr_result_image, ocrlines); |
3950 | -// |
3951 | -// } |
3952 | -// |
3953 | -// VLOG("OCR-Result", ocr_result_image); |
3954 | - |
3955 | - |
3956 | -} |
3957 | - |
3958 | - |
3959 | -void |
3960 | -cvgui::getLineBlobsAsIndividualWords(const Mat& screen, vector<LineBlob>& output_lineblobs){ |
3961 | - |
3962 | - Mat screen_gray; |
3963 | - cvtColor(screen,screen_gray,CV_RGB2GRAY); |
3964 | - |
3965 | - Mat blobs_mask; |
3966 | - cvgui::computeUnitBlobs(screen, blobs_mask); |
3967 | - |
3968 | - Mat dark; |
3969 | - Util::rgb2grayC3(screen,dark); |
3970 | - dark = dark * 0.5; |
3971 | - |
3972 | - vector<Blob> blobs; |
3973 | - cvgui::extractBlobs(blobs_mask, blobs); |
3974 | - |
3975 | - cvgui::calculateColor(blobs, screen, blobs_mask); |
3976 | - |
3977 | - // draw blobs |
3978 | - Mat result_blobs = dark.clone(); |
3979 | - Painter::drawBlobs(result_blobs, blobs, Scalar(255,255,0)); |
3980 | - VLOG("blobs-extracted",result_blobs); |
3981 | - |
3982 | - |
3983 | - vector<Blob> filtered_blobs; |
3984 | - for (vector<Blob>::iterator it = blobs.begin(); |
3985 | - it != blobs.end(); ++it){ |
3986 | - |
3987 | - Blob& blob = *it; |
3988 | - |
3989 | - // if (blob.height < 3 && blob.width < 3) |
3990 | - // continue; |
3991 | - // |
3992 | - // if (blob.height < 4) |
3993 | - // continue; |
3994 | - |
3995 | - filtered_blobs.push_back(blob); |
3996 | - } |
3997 | - |
3998 | - Mat result_filtered_blobs = dark.clone(); |
3999 | - Painter::drawBlobs(result_filtered_blobs, filtered_blobs, Scalar(255,255,0)); |
4000 | - |
4001 | - VLOG("blobs-filtered",result_filtered_blobs); |
4002 | - |
4003 | - |
4004 | - Mat result_lineblobs = dark.clone(); |
4005 | - |
4006 | - vector<LineBlob> lineblobs; |
4007 | - cvgui::linkBlobsIntoLineBlobs(filtered_blobs, lineblobs, 3); |
4008 | - |
4009 | - Painter::drawLineBlobs(result_lineblobs, lineblobs, Scalar(255,255,0)); |
4010 | - VLOG("lineblobs", result_lineblobs); |
4011 | - |
4012 | - |
4013 | - Mat result_lineblobs_filtered = dark.clone(); |
4014 | - vector<LineBlob> filtered_lineblobs; |
4015 | - |
4016 | - // Calculate the bounding rectangle of each line of linked blobs |
4017 | - for (vector<LineBlob>::iterator it_lines = lineblobs.begin(); |
4018 | - it_lines != lineblobs.end(); ++ it_lines){ |
4019 | - |
4020 | - LineBlob& line = *it_lines; |
4021 | - |
4022 | - // Ignore lines with fewer than X elements |
4023 | -// if (line.blobs.size()<2) |
4024 | -// continue; |
4025 | - |
4026 | - if (line.height < 3) |
4027 | - continue; |
4028 | - |
4029 | - filtered_lineblobs.push_back(line); |
4030 | - } |
4031 | - |
4032 | - |
4033 | - |
4034 | - Painter::drawLineBlobs(result_lineblobs_filtered, filtered_lineblobs, Scalar(255,255,0)); |
4035 | - VLOG("lineblobs-filtered", result_lineblobs_filtered); |
4036 | - |
4037 | - |
4038 | - |
4039 | - output_lineblobs = filtered_lineblobs; |
4040 | - |
4041 | - // Mat result_merged_blobs = dark.clone(); |
4042 | -// |
4043 | -// vector<LineBlob> merged_lineblobs; |
4044 | -// cvgui::mergeLineBlobs(filtered_lineblobs, merged_lineblobs); |
4045 | -// Painter::drawLineBlobs(result_merged_blobs, merged_lineblobs, Scalar(255,255,0)); |
4046 | -// VLOG("lineblobs-merged", result_merged_blobs); |
4047 | -// |
4048 | -// |
4049 | -// vector<ParagraphBlob> parablobs; |
4050 | -// cvgui::linkLineBlobsIntoPagagraphBlobs(merged_lineblobs, parablobs); |
4051 | -// |
4052 | -// Mat result_linked_parablobs = dark.clone(); |
4053 | -// |
4054 | -// Painter::drawParagraphBlobs(result_linked_parablobs, parablobs, Scalar(255,0,0)); |
4055 | -// |
4056 | -// VLOG("paragraph-linked", result_linked_parablobs); |
4057 | -// |
4058 | -// |
4059 | -// Mat screen_dark = screen * 0.2; |
4060 | -// Mat ocr_result_image = screen_dark; |
4061 | -// |
4062 | -// |
4063 | -// for (vector<ParagraphBlob>::iterator it = parablobs.begin(); |
4064 | -// it != parablobs.end(); ++it){ |
4065 | -// |
4066 | -// |
4067 | -// ParagraphBlob& parablob = *it; |
4068 | -// |
4069 | -// vector<OCRLine> ocrlines; |
4070 | -// |
4071 | -// cvgui::run_ocr_on_lineblobs(parablob.lineblobs, screen_gray, ocrlines); |
4072 | -// |
4073 | -// Painter::drawOCRLines(ocr_result_image, ocrlines); |
4074 | -// |
4075 | -// } |
4076 | -// |
4077 | -// VLOG("OCR-Result", ocr_result_image); |
4078 | -} |
4079 | - |
4080 | -void |
4081 | -cvgui::segmentScreenshot(const Mat& screen, vector<Blob>& text_blobs, vector<Blob>& image_blobs){ |
4082 | - |
4083 | - VLOG("Input", screen); |
4084 | - |
4085 | - Mat gray, screen_gray; |
4086 | - if(screen.channels() > 1){ |
4087 | - cvtColor(screen,gray,CV_RGB2GRAY); |
4088 | - } |
4089 | - else |
4090 | - gray = screen; |
4091 | - |
4092 | - screen_gray = gray.clone(); |
4093 | - |
4094 | - adaptiveThreshold(gray, gray, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY_INV, 5, 1); |
4095 | - VLOG("AdaptiveThresholded", gray); |
4096 | - |
4097 | - |
4098 | - Mat lines; |
4099 | - cvgui::findLongLines(gray, lines); |
4100 | - |
4101 | - Mat lines_viz = lines.clone(); |
4102 | - dilate(lines_viz, lines_viz, Mat::ones(4,4,CV_8UC1)); |
4103 | - VLOG("LongLinesFound", lines_viz); |
4104 | - |
4105 | - Mat not_lines; |
4106 | - bitwise_not(lines, not_lines); |
4107 | - |
4108 | - Mat foreground; |
4109 | - bitwise_and(gray, not_lines, foreground); |
4110 | - |
4111 | - gray.setTo(0, lines); |
4112 | - VLOG("LongLinesRemoved",gray); |
4113 | - |
4114 | - |
4115 | - denoise(gray); |
4116 | - VLOG("NoiseRemoved", gray); |
4117 | - |
4118 | - dilate(gray,gray,Mat::ones(1,3,CV_8UC1)); |
4119 | - VLOG("Dilated",gray); |
4120 | - |
4121 | - vector<Rect> rects; |
4122 | - //cvgui::extractRects(gray, rects); |
4123 | - |
4124 | - vector<Blob> blobs; |
4125 | - cvgui::extractBlobs(gray, blobs); |
4126 | - |
4127 | - |
4128 | - Mat dilated = gray.clone(); |
4129 | - |
4130 | - |
4131 | - // visualization |
4132 | - Mat result; |
4133 | - Mat g; |
4134 | - cvtColor(screen, g, CV_RGB2GRAY); |
4135 | - |
4136 | - Mat ss[3] = {g,g,g}; |
4137 | - merge(ss,3,result); |
4138 | - result = result * 0.5; |
4139 | - |
4140 | - Mat bg = result.clone(); |
4141 | - Mat screen_darken = bg.clone(); |
4142 | - |
4143 | - |
4144 | - text_blobs.clear(); |
4145 | - |
4146 | - for (vector<Blob>::iterator b = blobs.begin(); b != blobs.end(); ++b){ |
4147 | - |
4148 | - Blob& blob = *b; |
4149 | - Rect& bound = blob; |
4150 | - Mat part(screen, bound); |
4151 | - //paste(part, result, r->x, r->y); |
4152 | - |
4153 | - Mat p = part.clone(); |
4154 | - Mat g; |
4155 | - cvtColor(p, g, CV_RGB2GRAY); |
4156 | - adaptiveThreshold(g, g, 255, |
4157 | - ADAPTIVE_THRESH_MEAN_C, |
4158 | - THRESH_BINARY_INV, 3, 1); |
4159 | - vector<Rect> rs; |
4160 | - cvgui::extractSmallRects(g, rs); |
4161 | - for (vector<Rect>::iterator r = rs.begin();r != rs.end(); ++r){ |
4162 | - r->x += bound.x; |
4163 | - r->y += bound.y; |
4164 | - } |
4165 | - |
4166 | - vector<Rect> rs0; |
4167 | - for (vector<Rect>::iterator q = rs.begin(); |
4168 | - q != rs.end(); ++q){ |
4169 | - |
4170 | - // exclude overly short element (e.g., dot of i) |
4171 | - if (q->height < 5) |
4172 | - continue; |
4173 | - |
4174 | - rs0.push_back(*q); |
4175 | - } |
4176 | - |
4177 | - rs = rs0; |
4178 | - |
4179 | - // re-calculate the bounds |
4180 | - int x1,y1,x2,y2; |
4181 | - x1 = bound.x + bound.width; |
4182 | - y1 = bound.y + bound.height; |
4183 | - x2 = bound.x; |
4184 | - y2 = bound.y; |
4185 | - |
4186 | - for (vector<Rect>::iterator r = rs.begin(); |
4187 | - r != rs.end(); ++r){ |
4188 | - x1 = min(x1, r->x); |
4189 | - y1 = min(y1, r->y); |
4190 | - x2 = max(x2, r->x + r->width); |
4191 | - y2 = max(y2, r->y + r->height); |
4192 | - } |
4193 | - |
4194 | - //blob.bound = Rect(x1-2,y1-2,x2-x1+4,y2-y1+4); |
4195 | - //blob.bound = Rect(x1,y1,x2-x1,y2-y1); |
4196 | - |
4197 | - // make the bound bigger to be consistent with the dilated blobs |
4198 | - blob = Blob(Rect(x1-2,y1-1,x2-x1+4,y2-y1+2)); |
4199 | - |
4200 | - |
4201 | - int MINIMUM_NUM_CHARBLOBS = 2; |
4202 | - |
4203 | - if (cvgui::areHorizontallyAligned(rs) && rs.size()>=MINIMUM_NUM_CHARBLOBS) |
4204 | - Painter::drawRects(result, rs, Scalar(0,255,0)); |
4205 | - else |
4206 | - Painter::drawRects(result, rs, Scalar(0,0,255)); |
4207 | - |
4208 | - if (cvgui::areHorizontallyAligned(rs) && rs.size()>=MINIMUM_NUM_CHARBLOBS){ |
4209 | - text_blobs.push_back(blob); |
4210 | - } |
4211 | - |
4212 | - } |
4213 | - |
4214 | - //drawRects(result, rects, Scalar(255,0,0)); |
4215 | - Painter::drawBlobs(result, blobs, Scalar(255,0,0)); |
4216 | - |
4217 | - VLOG("TextBlocksExtracted",result); |
4218 | - |
4219 | - |
4220 | - |
4221 | - Mat text_mask = Mat::zeros(screen.size(), CV_8UC1); |
4222 | - |
4223 | - |
4224 | - for (vector<Blob>::iterator b = text_blobs.begin(); |
4225 | - b != text_blobs.end(); ++b){ |
4226 | - |
4227 | - Rect& r = *b; |
4228 | - Mat m(text_mask, |
4229 | - Range(r.y,r.y+r.height), |
4230 | - Range(r.x,r.x+r.width)); |
4231 | - |
4232 | - m = 255; |
4233 | - |
4234 | - } |
4235 | - |
4236 | - VLOG("TextBinaryMaskComputed", text_mask); |
4237 | - |
4238 | - |
4239 | - |
4240 | - |
4241 | - gray.setTo(0, text_mask); |
4242 | - VLOG("AfterTextRemoved",gray); |
4243 | - |
4244 | - dilate(gray,gray,Mat()); |
4245 | - VLOG("DilatedAgain",gray); |
4246 | - |
4247 | - Mat dilated_again = gray.clone(); |
4248 | - |
4249 | - vector<Blob> temp; |
4250 | - //cvgui::extractRects(gray, temp); |
4251 | - cvgui::extractBlobs(gray, temp); |
4252 | - |
4253 | - // only keep image rects larger than n pixels |
4254 | - |
4255 | - const int MIN_IMAGE_RECT_AREA = 150; |
4256 | - |
4257 | - image_blobs.clear(); |
4258 | - for (vector<Blob>::iterator b = temp.begin(); |
4259 | - b != temp.end(); ++b){ |
4260 | - |
4261 | - if (b->width * b->height < MIN_IMAGE_RECT_AREA) |
4262 | - continue; |
4263 | - |
4264 | - // // blob is too big, something is wrong |
4265 | - // if (b->bound.width > 0.8 * screen.width) |
4266 | - // continue; |
4267 | - // if (b->bound.height > 0.8 * screen.height) |
4268 | - // continue; |
4269 | - |
4270 | - image_blobs.push_back(*b); |
4271 | - |
4272 | - } |
4273 | - |
4274 | - Mat image_result = bg.clone(); |
4275 | - |
4276 | - Painter::drawBlobs(image_result, image_blobs, Scalar(0,0,255)); |
4277 | - VLOG("ImageRecordsExtracted", image_result); |
4278 | - |
4279 | - return; |
4280 | - |
4281 | - Mat ui_mask = Mat::zeros(screen.size(), CV_8UC1); |
4282 | - Mat photo_mask = Mat::zeros(screen.size(), CV_8UC1); |
4283 | - for (vector<Blob>::iterator b = image_blobs.begin(); |
4284 | - b != image_blobs.end(); ++b){ |
4285 | - |
4286 | - Rect& r = *b; |
4287 | - Mat mask; |
4288 | - if (r.height < 100) |
4289 | - mask = ui_mask; |
4290 | - else |
4291 | - mask = photo_mask; |
4292 | - |
4293 | - Mat m(mask, |
4294 | - Range(r.y,r.y+r.height), |
4295 | - Range(r.x,r.x+r.width)); |
4296 | - |
4297 | - m = 255; |
4298 | - } |
4299 | - |
4300 | - VLOG("UIMask", ui_mask); |
4301 | - VLOG("PhotoMask", photo_mask); |
4302 | - |
4303 | - Mat segmap; |
4304 | - Mat segmapr; |
4305 | - Mat segmapg; |
4306 | - Mat segmapb; |
4307 | - |
4308 | - bitwise_and(dilated,text_mask,segmapr); |
4309 | - bitwise_and(dilated,ui_mask,segmapg); |
4310 | - bitwise_and(dilated_again,photo_mask,segmapb); |
4311 | - //segmapb = photo_mask; |
4312 | - |
4313 | - |
4314 | - Mat cs[3] = {segmapb, segmapg,segmapr}; |
4315 | - merge(cs,3,segmap); |
4316 | - VLOG("SegMap", segmap); |
4317 | - |
4318 | - |
4319 | - //Mat wordmap = screen_darken.clone();//segmap.clone(); |
4320 | - Mat wordmap = Mat::zeros(screen.size(), CV_8UC3); |
4321 | - |
4322 | - |
4323 | - screen.copyTo(wordmap, segmapg); |
4324 | - screen.copyTo(wordmap, photo_mask); |
4325 | - screen.copyTo(wordmap, text_mask); |
4326 | - |
4327 | - |
4328 | - |
4329 | - Mat random_ids = Mat::ones(1,100,CV_8UC1); |
4330 | - randu(random_ids, 22, 80); |
4331 | - |
4332 | - Scalar white(255,255,255); |
4333 | - Scalar black(0,0,0); |
4334 | - Scalar yellow(255,255,0); |
4335 | - |
4336 | - |
4337 | - int i = 0; |
4338 | - |
4339 | - for (vector<Blob>::iterator b = image_blobs.begin(); |
4340 | - b != image_blobs.end(); ++b){ |
4341 | - |
4342 | - Rect& r = *b; |
4343 | - |
4344 | - |
4345 | - char vwstr[100]; |
4346 | - |
4347 | - |
4348 | - if (r.height < 100){ |
4349 | - |
4350 | - int xc = r.x + r.width/2; |
4351 | - int yc = r.y + r.height/2; |
4352 | - |
4353 | - |
4354 | - // putTextWithBackgroundCentered(black, wordmap, "u12", Point(xc,yc), |
4355 | - // FONT_HERSHEY_SIMPLEX, 0.5, white); |
4356 | - |
4357 | - int id = random_ids.at<uchar>(0,i++); |
4358 | - sprintf(vwstr,"u%d",id); |
4359 | - |
4360 | -// putTextWithBackgroundCentered(white, wordmap, vwstr, Point(xc,yc), |
4361 | -// FONT_HERSHEY_DUPLEX, 0.5, black); |
4362 | - |
4363 | - |
4364 | - }else{ |
4365 | - |
4366 | - |
4367 | - SURF surf_extractor(6.0e3); |
4368 | - vector<KeyPoint> keypoints; |
4369 | - |
4370 | - // printf("Extracting keypoints\n"); |
4371 | - surf_extractor(screen_gray, photo_mask, keypoints); |
4372 | - //printf("Extracted %d keypoints from the image\n", (int)keypoints.size()); |
4373 | - |
4374 | - for (vector<KeyPoint>::iterator it = keypoints.begin(); it != keypoints.end(); ++it){ |
4375 | - KeyPoint& p = *it; |
4376 | - |
4377 | - circle(wordmap, p.pt, p.size*1.5, yellow); |
4378 | - |
4379 | - // putTextWithBackgroundCentered(black, wordmap, "v12", p.pt, |
4380 | - // FONT_HERSHEY_SIMPLEX, 0.5, white); |
4381 | - |
4382 | - int id = random_ids.at<uchar>(0,i++); |
4383 | - sprintf(vwstr,"s%d",id); |
4384 | - |
4385 | -// putTextWithBackgroundCentered(white, wordmap, vwstr, p.pt, |
4386 | -// FONT_HERSHEY_DUPLEX, 0.5, black); |
4387 | - |
4388 | - } |
4389 | - } |
4390 | - |
4391 | - |
4392 | - } |
4393 | - |
4394 | - VLOG("WordMap", wordmap); |
4395 | -} |
4396 | - |
4397 | - |
4398 | - |
4399 | - |
4400 | -static int L1dist(Vec3b p1, Vec3b p2){ |
4401 | - return max(p1[0],p2[0])-min(p1[0],p2[0])+ |
4402 | - max(p1[1],p2[1])-min(p1[1],p2[1])+ |
4403 | - max(p1[2],p2[2])-min(p1[2],p2[2]); |
4404 | -} |
4405 | - |
4406 | - |
4407 | - |
4408 | -bool |
4409 | -cvgui::areHorizontallyAligned(const vector<Rect>& rects){ |
4410 | - |
4411 | - if (rects.size() <= 1) |
4412 | - return true; |
4413 | - |
4414 | - vector<Rect> sorted_rects = rects; |
4415 | - sort(sorted_rects, sort_by_x); |
4416 | - |
4417 | - int ymin = 10000; |
4418 | - int ymax = 0; |
4419 | - |
4420 | - bool no_overlap = true; |
4421 | - for (vector<Rect>::const_iterator r = sorted_rects.begin() + 1; |
4422 | - r != sorted_rects.end(); ++r){ |
4423 | - |
4424 | - no_overlap = no_overlap && (r->x >= (r-1)->x + (r-1)->width - 2); |
4425 | - |
4426 | - int baseline = r->y + r->height; |
4427 | - ymin = min(baseline, ymin); |
4428 | - ymax = max(baseline, ymax); |
4429 | - } |
4430 | - |
4431 | - bool baseline_aligned = (ymax - ymin < 10); |
4432 | - |
4433 | - int minv = 10000; |
4434 | - int maxv = 0; |
4435 | - for (vector<Rect>::const_iterator r = sorted_rects.begin(); |
4436 | - r != sorted_rects.end(); ++r){ |
4437 | - |
4438 | - int v = r->height; |
4439 | - minv = min(v, minv); |
4440 | - maxv = max(v, maxv); |
4441 | - } |
4442 | - |
4443 | - bool height_similar = (maxv - minv < 10); |
4444 | - |
4445 | - // if the difference between the highest and lowest baseline |
4446 | - // is too large, it means the rects are not alginged horizontally |
4447 | - |
4448 | - return baseline_aligned && height_similar && no_overlap; |
4449 | -} |
4450 | - |
4451 | - |
4452 | -bool |
4453 | -cvgui::hasMoreThanNUniqueColors(const Mat& src, int n){ |
4454 | - |
4455 | - |
4456 | - Mat_<Vec3b>::const_iterator it = src.begin<Vec3b>(), |
4457 | - itEnd = src.end<Vec3b>(); |
4458 | - |
4459 | - |
4460 | - vector< pair<Vec3b,int> > colors; |
4461 | - //vector<int> counts; |
4462 | - colors.push_back( pair<Vec3b,int>(*it,1) ); |
4463 | - ++it; |
4464 | - |
4465 | - for(; it != itEnd; ++it){ |
4466 | - |
4467 | - bool matched; |
4468 | - matched = false; |
4469 | - for (vector< pair<Vec3b,int> >::iterator c = colors.begin(); |
4470 | - c != colors.end(); |
4471 | - ++c){ |
4472 | - |
4473 | - Vec3b& color = (*c).first; |
4474 | - int& count = (*c).second; |
4475 | - |
4476 | - int d = L1dist((*it), (color)); |
4477 | - //cout << d << endl; |
4478 | - if (d < 150){ |
4479 | - matched = true; |
4480 | - count++; |
4481 | - break; |
4482 | - } |
4483 | - } |
4484 | - |
4485 | - if (!matched){ |
4486 | - |
4487 | - // if (colors.size() == 4) |
4488 | - // return true; |
4489 | - // else |
4490 | - colors.push_back(pair<Vec3b,int>(*it,1)); |
4491 | - |
4492 | - } |
4493 | - |
4494 | - } |
4495 | - |
4496 | - dout() << endl << endl; |
4497 | - for (vector< pair<Vec3b,int> >::iterator c = colors.begin(); |
4498 | - c != colors.end(); |
4499 | - ++c){ |
4500 | - |
4501 | - Vec3b& color = (*c).first; |
4502 | - int& count = (*c).second; |
4503 | - //cout << count << endl; |
4504 | - } |
4505 | - |
4506 | - return (colors.size() > 5); |
4507 | -} |
4508 | - |
4509 | - |
4510 | -void |
4511 | -cvgui::extractSmallRects(const Mat& src, |
4512 | - vector<Rect>& rects){ |
4513 | - |
4514 | - Mat copy = src.clone(); |
4515 | - |
4516 | - vector<vector<Point> > contours; |
4517 | - findContours(copy, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); |
4518 | - |
4519 | - for (vector<vector<Point> >::iterator contour = contours.begin(); |
4520 | - contour != contours.end(); ++contour){ |
4521 | - |
4522 | - Rect bound = boundingRect(Mat(*contour)); |
4523 | - rects.push_back(bound); |
4524 | - } |
4525 | - |
4526 | -} |
4527 | - |
4528 | -void |
4529 | -cvgui::calculateColor(vector<Blob>& blobs, |
4530 | - const Mat& color_image, |
4531 | - const Mat& foreground_mask){ |
4532 | - |
4533 | - |
4534 | - for (vector<Blob>::iterator it = blobs.begin(); |
4535 | - it != blobs.end(); ++it){ |
4536 | - |
4537 | - Blob& blob = *it; |
4538 | - |
4539 | - |
4540 | - Mat part(color_image, blob); |
4541 | - Mat mask(foreground_mask, blob); |
4542 | - Scalar mean, stddev; |
4543 | - meanStdDev(part, mean, stddev, mask); |
4544 | - |
4545 | - blob.mr = mean[0]; |
4546 | - blob.mg = mean[1]; |
4547 | - blob.mb = mean[2]; |
4548 | - |
4549 | - } |
4550 | - |
4551 | -} |
4552 | - |
4553 | - |
4554 | -void |
4555 | -cvgui::extractBlobs(const Mat& src, vector<Blob>& blobs){ |
4556 | - |
4557 | - Mat copy = src.clone(); |
4558 | - blobs.clear(); |
4559 | - |
4560 | - vector<vector<Point> > contours; |
4561 | - findContours(copy, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); |
4562 | - |
4563 | - |
4564 | - for (vector<vector<Point> >::iterator contour = contours.begin(); |
4565 | - contour != contours.end(); ++contour){ |
4566 | - |
4567 | - |
4568 | - double area = contourArea(Mat(*contour)); |
4569 | - |
4570 | - Rect bound = boundingRect(Mat(*contour)); |
4571 | - |
4572 | - |
4573 | - |
4574 | - |
4575 | - Blob blob(bound); |
4576 | - blob.area = area; |
4577 | - blobs.push_back(blob); |
4578 | - |
4579 | - } |
4580 | - |
4581 | - |
4582 | - |
4583 | - |
4584 | - |
4585 | -} |
4586 | - |
4587 | - |
4588 | -void |
4589 | -cvgui::extractRects(const Mat& src, |
4590 | - vector<Rect>& rects){ |
4591 | - |
4592 | - Mat copy = src.clone(); |
4593 | - rects.clear(); |
4594 | - |
4595 | - |
4596 | - vector<vector<Point> > contours; |
4597 | - findContours(copy, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); |
4598 | - |
4599 | - |
4600 | - for (vector<vector<Point> >::iterator contour = contours.begin(); |
4601 | - contour != contours.end(); ++contour){ |
4602 | - |
4603 | - |
4604 | - double area = contourArea(Mat(*contour)); |
4605 | - |
4606 | - Rect bound = boundingRect(Mat(*contour)); |
4607 | - |
4608 | - |
4609 | - // too small |
4610 | - if (bound.width < 6 || bound.height < 6) |
4611 | - continue; |
4612 | - |
4613 | - // too empty |
4614 | - if (bound.height > 100 && bound.width * bound.height * 0.50 > area) |
4615 | - continue; |
4616 | - |
4617 | - rects.push_back(bound); |
4618 | - |
4619 | - } |
4620 | - |
4621 | -} |
4622 | - |
4623 | -void |
4624 | -cvgui::findLongLines_Vertical(const Mat& src, Mat& dest, int min_length, int extension){ |
4625 | - dest = src.clone(); |
4626 | - |
4627 | - Mat maskT, destT; |
4628 | - transpose(dest,destT); |
4629 | - cvgui::findLongLines_Horizontal(destT,maskT,min_length, extension); |
4630 | - |
4631 | - Mat maskTT; |
4632 | - transpose(maskT,maskTT); |
4633 | - dest = maskTT; |
4634 | -} |
4635 | - |
4636 | - |
4637 | -void |
4638 | -cvgui::findLongLines(const Mat& src, Mat& dest, int min_length, int extension){ |
4639 | - |
4640 | - Mat copy = src.clone(); |
4641 | - Mat v,h; |
4642 | - |
4643 | - cvgui::findLongLines_Horizontal(copy, h, min_length, extension); |
4644 | - |
4645 | - |
4646 | - cvgui::findLongLines_Vertical(copy, v, min_length, extension); |
4647 | - |
4648 | -// Mat maskT, destT; |
4649 | -// transpose(dest,destT); |
4650 | -// cvgui::findLongLines_Horizontal(destT,maskT,min_length, extension); |
4651 | -// |
4652 | -// Mat maskTT; |
4653 | -// transpose(maskT,maskTT); |
4654 | - |
4655 | - |
4656 | - bitwise_or(v,h,dest); |
4657 | - |
4658 | -} |
4659 | - |
4660 | - |
4661 | -//void |
4662 | -//cvgui::filterLineSegments(const Mat& src, Mat& dest, |
4663 | -// int min_length, int max_length){ |
4664 | -// |
4665 | -// typedef uchar T; |
4666 | -// |
4667 | -// int extension = 5; |
4668 | -// |
4669 | -// dest = Mat::zeros(src.rows,src.cols,CV_8UC1); |
4670 | -// |
4671 | -// Size size = src.size(); |
4672 | -// for( int i = 0; i < size.height; i +=1 ){ |
4673 | -// |
4674 | -// const T* ptr1 = src.ptr<T>(i); |
4675 | -// T* ptr2 = dest.ptr<T>(i); |
4676 | -// |
4677 | -// bool has_previous_baseline = false; |
4678 | -// int previous_baseline_endpoint = 0; |
4679 | -// int current_baseline_startpoint = 0; |
4680 | -// |
4681 | -// |
4682 | -// for( int j = 1; j < size.width; j += 1 ){ |
4683 | -// |
4684 | -// |
4685 | -// if (ptr1[j] > 0 && ptr1[j-1] == 0){ |
4686 | -// current_baseline_startpoint = j; |
4687 | -// } |
4688 | -// |
4689 | -// if (ptr1[j-1] > 0 && (ptr1[j] == 0 || j == size.width - 1)){ |
4690 | -// |
4691 | -// |
4692 | -// // check for the condition of a baseline hypothesis |
4693 | -// // the length of the baseline must be > 15 |
4694 | -// if ((j - current_baseline_startpoint) > min_length){// || j == size.width - 1){ |
4695 | -// |
4696 | -// // int closeness_threshold = 1; |
4697 | -// // if (has_previous_baseline && |
4698 | -// // (current_baseline_startpoint - previous_baseline_endpoint) |
4699 | -// // <= closeness_threshold){ |
4700 | -// // |
4701 | -// // |
4702 | -// // // merge the current baseline with the previously baseline |
4703 | -// // for (int k=previous_baseline_endpoint; |
4704 | -// // k < current_baseline_startpoint; k += 1){ |
4705 | -// // ptr2[k] = ptr1[j]; |
4706 | -// // } |
4707 | -// // } |
4708 | -// |
4709 | -// // has_previous_baseline = true; |
4710 | -// //previous_baseline_endpoint = j; |
4711 | -// |
4712 | -// |
4713 | -// for (int k=current_baseline_startpoint; k < j; ++k){ |
4714 | -// ptr2[k] = 255; |
4715 | -// } |
4716 | -// |
4717 | -// for (int k=j; k < min(j+extension,size.width-1); ++k){ |
4718 | -// ptr2[k] = 255; |
4719 | -// } |
4720 | -// |
4721 | -// |
4722 | -// } |
4723 | -// |
4724 | -// // forming a new baseline hypothesis |
4725 | -// //current_baseline_startpoint = j+1; |
4726 | -// } |
4727 | -// } |
4728 | -// } |
4729 | -// |
4730 | -//} |
4731 | - |
4732 | - |
4733 | -void |
4734 | -cvgui::voteCenter_Vertical(const Mat& binary, Mat& dest, |
4735 | - int min_length, int tolerance, int distance){ |
4736 | - |
4737 | - dest = binary.clone(); |
4738 | - |
4739 | - Mat maskT, destT; |
4740 | - transpose(dest,destT); |
4741 | - cvgui::voteCenter_Horizontal(destT,maskT,min_length,tolerance,distance); |
4742 | - |
4743 | - Mat maskTT; |
4744 | - transpose(maskT,maskTT); |
4745 | - dest = maskTT; |
4746 | -} |
4747 | - |
4748 | -void |
4749 | -cvgui::voteCenter_Horizontal(const Mat& binary, Mat& dest, |
4750 | - int min_length, int tolerance, int distance){ |
4751 | - |
4752 | - typedef uchar T; |
4753 | - |
4754 | - dest = Mat::zeros(binary.rows,binary.cols,CV_8UC1); |
4755 | - |
4756 | - Size size = binary.size(); |
4757 | - for( int i = 0; i < size.height; i +=1 ){ |
4758 | - |
4759 | - const T* ptr1 = binary.ptr<T>(i); |
4760 | - T* ptr2 = 0; |
4761 | - //dest.ptr<T>(i); |
4762 | -// |
4763 | -// |
4764 | -// T* ptru = 0; |
4765 | -// T* ptrb = 0; |
4766 | -// |
4767 | - int grid = 5; |
4768 | - |
4769 | - |
4770 | - int gi = grid*(i+distance)/grid; |
4771 | - |
4772 | - if (gi >= 0 && gi < size.height){ |
4773 | - ptr2 = dest.ptr<T>(i+distance); |
4774 | - } |
4775 | - |
4776 | -// if (grid*(i+distance)/grid<size.height){ |
4777 | -// ptrb = dest.ptr<T>(i+distance); |
4778 | -// } |
4779 | - |
4780 | - bool has_previous_baseline = false; |
4781 | - int previous_baseline_endpoint = 0; |
4782 | - int current_baseline_startpoint = 0; |
4783 | - |
4784 | - |
4785 | - for( int j = 1; j < size.width; j += 1 ){ |
4786 | - |
4787 | - |
4788 | - if (ptr1[j] > 0 && ptr1[j-1] == 0){ |
4789 | - current_baseline_startpoint = j; |
4790 | - } |
4791 | - |
4792 | - if (ptr1[j-1] > 0 && (ptr1[j] == 0 || j == size.width - 1)){ |
4793 | - |
4794 | - |
4795 | - // check for the condition of a baseline hypothesis |
4796 | - // the length of the baseline must be > 15 |
4797 | - if ((j - current_baseline_startpoint) > min_length){// || j == size.width - 1){ |
4798 | - |
4799 | - |
4800 | - |
4801 | - for (int k=current_baseline_startpoint+min_length/2; k < j-min_length/2; ++k){ |
4802 | - |
4803 | - if (ptr2) |
4804 | - ptr2[k] = 255; |
4805 | - } |
4806 | - |
4807 | - for (int k=j-min_length/2; k < min(j-min_length/2+tolerance,size.width-1); ++k){ |
4808 | - |
4809 | - if (ptr2) |
4810 | - ptr2[k] = 255; |
4811 | - |
4812 | - } |
4813 | - |
4814 | - |
4815 | - } |
4816 | - |
4817 | - // forming a new baseline hypothesis |
4818 | - //current_baseline_startpoint = j+1; |
4819 | - } |
4820 | - } |
4821 | - } |
4822 | - |
4823 | -} |
4824 | - |
4825 | -void |
4826 | -cvgui::findLongLines_Horizontal(const Mat& binary, Mat& dest, |
4827 | - int min_length, int extension){ |
4828 | - |
4829 | - typedef uchar T; |
4830 | - |
4831 | - dest = Mat::zeros(binary.rows,binary.cols,CV_8UC1); |
4832 | - |
4833 | - Size size = binary.size(); |
4834 | - for( int i = 0; i < size.height; i +=1 ){ |
4835 | - |
4836 | - const T* ptr1 = binary.ptr<T>(i); |
4837 | - T* ptr2 = dest.ptr<T>(i); |
4838 | - |
4839 | - bool has_previous_baseline = false; |
4840 | - int previous_baseline_endpoint = 0; |
4841 | - int current_baseline_startpoint = 0; |
4842 | - |
4843 | - |
4844 | - |
4845 | - |
4846 | - for( int j = 1; j < size.width; j += 1 ){ |
4847 | - |
4848 | - |
4849 | - if (ptr1[j] > 0 && ptr1[j-1] == 0){ |
4850 | - current_baseline_startpoint = j; |
4851 | - } |
4852 | - |
4853 | - if (ptr1[j-1] > 0 && (ptr1[j] == 0 || j == size.width - 1)){ |
4854 | - |
4855 | - |
4856 | - // check for the condition of a baseline hypothesis |
4857 | - // the length of the baseline must be > 15 |
4858 | - if ((j - current_baseline_startpoint) > min_length){// || j == size.width - 1){ |
4859 | - |
4860 | - // int closeness_threshold = 1; |
4861 | - // if (has_previous_baseline && |
4862 | - // (current_baseline_startpoint - previous_baseline_endpoint) |
4863 | - // <= closeness_threshold){ |
4864 | - // |
4865 | - // |
4866 | - // // merge the current baseline with the previously baseline |
4867 | - // for (int k=previous_baseline_endpoint; |
4868 | - // k < current_baseline_startpoint; k += 1){ |
4869 | - // ptr2[k] = ptr1[j]; |
4870 | - // } |
4871 | - // } |
4872 | - |
4873 | - // has_previous_baseline = true; |
4874 | - //previous_baseline_endpoint = j; |
4875 | - |
4876 | - |
4877 | - for (int k=current_baseline_startpoint; k < j; ++k){ |
4878 | - ptr2[k] = 255; |
4879 | - } |
4880 | - |
4881 | - for (int k=j; k < min(j+extension,size.width-1); ++k){ |
4882 | - ptr2[k] = 255; |
4883 | - } |
4884 | - |
4885 | - |
4886 | - } |
4887 | - |
4888 | - // forming a new baseline hypothesis |
4889 | - //current_baseline_startpoint = j+1; |
4890 | - } |
4891 | - } |
4892 | - } |
4893 | -} |
4894 | - |
4895 | - |
4896 | -Mat |
4897 | -cvgui::obtainGrayBackgroundMask(const Mat& input){ |
4898 | - |
4899 | - Mat copy = input.clone(); |
4900 | - |
4901 | - Mat_<Vec3b>::iterator it = copy.begin<Vec3b>(), |
4902 | - itEnd = copy.end<Vec3b>(); |
4903 | - for(; it != itEnd; ++it){ |
4904 | - |
4905 | - uchar& b = (*it)[0]; |
4906 | - uchar& g = (*it)[1]; |
4907 | - uchar& r = (*it)[2]; |
4908 | - |
4909 | - if (r == 0 && b == 0 && g == 0){ |
4910 | - r = 1; b = 1; g = 1; |
4911 | - } |
4912 | - |
4913 | - if (b > 50 && |
4914 | - abs(b-g) < 10 && abs(g-b) < 10 && abs(b-r) < 10){ |
4915 | - r = 0; |
4916 | - g = 0; |
4917 | - b = 0; |
4918 | - } |
4919 | - |
4920 | - |
4921 | - |
4922 | - } |
4923 | - |
4924 | - |
4925 | - Mat ms[3]; |
4926 | - split(copy, ms); |
4927 | - |
4928 | - Mat mask; |
4929 | - threshold(ms[0],mask,0,255,THRESH_BINARY); |
4930 | - |
4931 | - dilate(mask,mask,Mat()); |
4932 | - |
4933 | - return mask; |
4934 | -} |
4935 | - |
4936 | - |
4937 | -Mat |
4938 | -cvgui::removeGrayBackground(const Mat& input){ |
4939 | - |
4940 | -// Mat copy = input.clone(); |
4941 | -// Mat mask; |
4942 | -// // (Size(copy.rows,copy.cols), CV_8UC1); |
4943 | -// |
4944 | -// Mat_<Vec3b>::iterator it = copy.begin<Vec3b>(), |
4945 | -// itEnd = copy.end<Vec3b>(); |
4946 | -// for(; it != itEnd; ++it){ |
4947 | -// |
4948 | -// uchar& b = (*it)[0]; |
4949 | -// uchar& g = (*it)[1]; |
4950 | -// uchar& r = (*it)[2]; |
4951 | -// |
4952 | -// if (r == 0 && b == 0 && g == 0){ |
4953 | -// r = 1; b = 1; g = 1; |
4954 | -// } |
4955 | -// |
4956 | -// if (b > 50 && |
4957 | -// abs(b-g) < 10 && abs(g-b) < 10 && abs(b-r) < 10){ |
4958 | -// r = 0; |
4959 | -// g = 0; |
4960 | -// b = 0; |
4961 | -// } |
4962 | -// |
4963 | -// |
4964 | -// |
4965 | -// } |
4966 | -// |
4967 | -// |
4968 | -// Mat ms[3]; |
4969 | -// split(copy, ms); |
4970 | -// |
4971 | -// //threshold(ms[0],mask,0,255,THRESH_BINARY_INV); |
4972 | -// threshold(ms[0],mask,0,255,THRESH_BINARY); |
4973 | -// |
4974 | -// dilate(mask,mask,Mat()); |
4975 | -// |
4976 | -// |
4977 | -// vector<vector<Point> > contours; |
4978 | -// findContours(ms[0], contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); |
4979 | -// |
4980 | -// Scalar red(0,0,255); |
4981 | -// //drawContours(copy, contours, -1, red); |
4982 | -// |
4983 | -// |
4984 | -// vector<Rect> boundingRects; |
4985 | -// |
4986 | -// for (vector<vector<Point> >::iterator contour = contours.begin(); |
4987 | -// contour != contours.end(); ++contour){ |
4988 | -// |
4989 | -// |
4990 | -// double area = contourArea(Mat(*contour)); |
4991 | -// |
4992 | -// Rect bound = boundingRect(Mat(*contour)); |
4993 | -// |
4994 | -// |
4995 | -// if (bound.width * bound.height * 0.5 > area) |
4996 | -// continue; |
4997 | -// |
4998 | -// boundingRects.push_back(bound); |
4999 | -// |
5000 | -// rectangle(copy, |
The diff has been truncated for viewing.
Thanks. Uploaded.