Skip to content

Commit 80c2013

Browse files
committed
2 parents 3181313 + d40808b commit 80c2013

22 files changed

Lines changed: 476 additions & 114 deletions

SerialPrograms/CMakeLists.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,18 @@ if (WIN32)
294294
MAP_IMPORTED_CONFIG_MINSIZEREL RELEASE
295295
)
296296

297-
target_link_libraries(
298-
SerialProgramsLib PRIVATE
299-
tesseractPA.lib
300-
OpenCV_lib
301-
ONNX_lib
302-
ONNX_Providers_lib
303-
dpp_lib
304-
discord_lib
305-
xinput
306-
dinput8
307-
dxguid
308-
)
297+
target_link_libraries(
298+
SerialProgramsLib PRIVATE
299+
tesseractPA.lib
300+
OpenCV_lib
301+
ONNX_lib
302+
ONNX_Providers_lib
303+
dpp_lib
304+
discord_lib
305+
xinput
306+
dinput8
307+
dxguid
308+
)
309309

310310
target_compile_definitions(
311311
SerialProgramsLib PUBLIC
@@ -708,4 +708,4 @@ if (QT_MAJOR GREATER_EQUAL 6)
708708
endif()
709709

710710
# Add command-line executable (GUI-free) from subdirectory
711-
include(Source/CommandLine/CommandLineExecutable.cmake)
711+
include(Source/CommandLine/CommandLineExecutable.cmake)

SerialPrograms/Source/CommonTools/Images/ImageTools.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "CommonFramework/ImageTypes/ImageRGB32.h"
99
#include "CommonFramework/ImageTools/ImageBoxes.h"
1010
#include "CommonFramework/ImageTools/FloatPixel.h"
11+
#include "CommonTools/Images/SolidColorTest.h"
1112
#include "ImageTools.h"
1213

1314
namespace PokemonAutomation{
@@ -47,6 +48,50 @@ ImageRGB32 image_diff_greyscale(const ImageViewRGB32& x, const ImageViewRGB32& y
4748

4849

4950

51+
ImagePixelBox find_contents_pixel_box(const ImageViewRGB32& image){
52+
const double MAX_SUM = 10;
53+
const double MAX_STDDEV = 10;
54+
55+
size_t top = 0;
56+
for (; top < image.height(); top++){
57+
ImageViewRGB32 line = image.sub_image(0, top, image.width(), 1);
58+
if (!is_black(line, MAX_SUM, MAX_STDDEV)){
59+
break;
60+
}
61+
}
62+
63+
size_t bot = image.height();
64+
for (; bot > top; bot--){
65+
ImageViewRGB32 line = image.sub_image(0, bot - 1, image.width(), 1);
66+
if (!is_black(line, MAX_SUM, MAX_STDDEV)){
67+
break;
68+
}
69+
}
70+
71+
size_t left = 0;
72+
for (; left < image.width(); left++){
73+
ImageViewRGB32 line = image.sub_image(left, 0, 1, image.height());
74+
if (!is_black(line, MAX_SUM, MAX_STDDEV)){
75+
break;
76+
}
77+
}
78+
79+
size_t right = image.width();
80+
for (; right > left; right--){
81+
ImageViewRGB32 line = image.sub_image(right - 1, 0, 1, image.height());
82+
if (!is_black(line, MAX_SUM, MAX_STDDEV)){
83+
break;
84+
}
85+
}
86+
87+
return ImagePixelBox(left, top, right, bot);
88+
}
89+
ImageFloatBox find_contents_float_box(const ImageViewRGB32& image){
90+
return pixelbox_to_floatbox(
91+
image.width(), image.height(),
92+
find_contents_pixel_box(image)
93+
);
94+
}
5095

5196

5297

SerialPrograms/Source/CommonTools/Images/ImageTools.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ namespace PokemonAutomation{
1212

1313
class ImageViewRGB32;
1414
class ImageRGB32;
15+
struct ImagePixelBox;
16+
struct ImageFloatBox;
1517

1618

1719
// Deprecated
1820
ImageRGB32 image_diff_greyscale(const ImageViewRGB32& x, const ImageViewRGB32& y);
1921

2022

23+
ImagePixelBox find_contents_pixel_box(const ImageViewRGB32& image);
24+
ImageFloatBox find_contents_float_box(const ImageViewRGB32& image);
25+
26+
2127

2228

2329

0 commit comments

Comments
 (0)