Skip to content

Commit abde37b

Browse files
committed
2 parents 63c1e60 + 163aa8f commit abde37b

File tree

7 files changed

+36
-12
lines changed

7 files changed

+36
-12
lines changed

SerialPrograms/Source/Kernels/BinaryImageFilters/Kernels_BinaryImage_BasicFilters_Core_64x8_arm64_NEON.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "Kernels_BinaryImage_BasicFilters_Routines.h"
1111
#include "Kernels_BinaryImage_BasicFilters_arm64_NEON.h"
1212

13+
1314
namespace PokemonAutomation{
1415
namespace Kernels{
1516

@@ -24,6 +25,8 @@ void filter_by_mask_64x8_arm64_NEON(
2425
}
2526

2627

28+
29+
2730
void compress_rgb32_to_binary_range_64x8_arm64_NEON(
2831
const uint32_t* image, size_t bytes_per_row,
2932
PackedBinaryMatrix_IB& matrix0, uint32_t mins0, uint32_t maxs0

SerialPrograms/Source/Kernels/BinaryImageFilters/Kernels_BinaryImage_BasicFilters_arm64_NEON.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
#include "Kernels/PartialWordAccess/Kernels_PartialWordAccess_arm64_NEON.h"
1111

12-
#include <iostream>
13-
using std::cout;
14-
using std::endl;
12+
// #include <iostream>
13+
// using std::cout;
14+
// using std::endl;
1515

1616
namespace PokemonAutomation{
1717
namespace Kernels{
@@ -149,8 +149,6 @@ class FilterByMask_arm64_NEON{
149149
const uint32x4_t m_zeros;
150150
};
151151

152-
153-
154152
// Compress given pixels buffer (of up to 64-pixel long) into bit map and store in one uint64_t.
155153
class Compressor_RgbRange_arm64_NEON{
156154
public:
@@ -178,13 +176,14 @@ class Compressor_RgbRange_arm64_NEON{
178176
bits |= convert16(pixels + c) << c;
179177
c += 16;
180178
}
181-
for(; c < count; c += 4){
179+
180+
count %= 16;
181+
for(size_t i = 0; i < count / 4; i++, c+=4){
182182
const uint8x16_t pixel = vld1q_u8((const uint8_t*)(pixels + c));
183183
bits |= convert4(pixel) << c;
184184
}
185185
count %= 4;
186186
if (count){
187-
c -= 4;
188187
PartialWordAccess_arm64_NEON loader(count * sizeof(uint32_t));
189188
const uint8x16_t pixel = loader.load(pixels + c);
190189
const uint64_t mask = ((uint64_t)1 << count) - 1;
@@ -273,6 +272,7 @@ class Compressor_RgbEuclidean_arm64_NEON{
273272
for(size_t i = 0; i < count / 4; i++, c+=4){
274273
bits |= convert4(pixels + c) << c;
275274
}
275+
count %= 4;
276276
if (count){
277277
PartialWordAccess_arm64_NEON loader(count * sizeof(uint32_t));
278278
const uint8x16_t pixel = loader.load(pixels + c);

SerialPrograms/Source/Kernels/Waterfill/Kernels_Waterfill_Session.tpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#include "Kernels/BinaryMatrix/Kernels_SparseBinaryMatrixCore.h"
1717
#include "Kernels_Waterfill_Session.h"
1818

19-
//#include <iostream>
20-
//using std::cout;
21-
//using std::endl;
19+
// #include <iostream>
20+
// using std::cout;
21+
// using std::endl;
2222

2323
namespace PokemonAutomation{
2424
namespace Kernels{

SerialPrograms/Source/PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,18 @@ bool is_selection_arrow(const ImageViewRGB32& image, const WaterfillObject& obje
8383
}
8484
std::vector<ImagePixelBox> find_selection_arrows(const ImageViewRGB32& image, size_t min_area){
8585
if (PreloadSettings::debug().IMAGE_TEMPLATE_MATCHING){
86-
std::cout << "Match SwSh selection arrow by waterfill, size range (" << min_area << ", SIZE_MAX)" << std::endl;
86+
std::cout << "Match SwSh selection arrow by waterfill, size range (" << min_area << ", SIZE_MAX) "
87+
<< "input image size " << image.width() << " x " << image.height() << std::endl;
8788
}
8889
PackedBinaryMatrix matrix = compress_rgb32_to_binary_max(image, 63, 63, 63);
8990
auto session = make_WaterfillSession(matrix);
9091
auto finder = session->make_iterator(min_area);
9192
std::vector<ImagePixelBox> ret;
9293
WaterfillObject object;
9394
while (finder->find_next(object, true)){
94-
// cout << object.min_x << "-" << object.max_x << ", " << object.min_y << "-" << object.max_y << endl;
95+
if (PreloadSettings::debug().IMAGE_TEMPLATE_MATCHING){
96+
std::cout << "Found object: " << object.min_x << "-" << object.max_x << ", " << object.min_y << "-" << object.max_y << std::endl;
97+
}
9598
if (is_selection_arrow(image, object)){
9699
ret.emplace_back(object);
97100
}

SerialPrograms/Source/Tests/PokemonSwSh_Tests.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ using std::endl;
3030

3131
namespace PokemonAutomation{
3232

33+
namespace NintendoSwitch{
34+
namespace PokemonSwSh{
35+
std::vector<ImagePixelBox> find_selection_arrows(const ImageViewRGB32& image, size_t min_area);
36+
}
37+
}
38+
3339
using namespace NintendoSwitch::PokemonSwSh;
3440

3541
int test_pokemonSwSh_YCommMenuDetector(const ImageViewRGB32& image, bool target){
@@ -125,4 +131,13 @@ int test_pokemonSwSh_BoxGenderDetector(const ImageViewRGB32& image, int target){
125131
return 0;
126132
}
127133

134+
int test_pokemonSwSh_SelectionArrowFinder(const ImageViewRGB32& image, int target){
135+
std::vector<ImagePixelBox> boxes = find_selection_arrows(image, 10);
136+
for(const auto& box : boxes){
137+
std::cout << "Found box: " << box.min_x << " " << box.max_x << " " << box.min_y << " " << box.max_y << std::endl;
138+
}
139+
TEST_RESULT_EQUAL(boxes.size(), (size_t)target);
140+
return 0;
141+
}
142+
128143
}

SerialPrograms/Source/Tests/PokemonSwSh_Tests.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ int test_pokemonSwSh_BoxShinySymbolDetector(const ImageViewRGB32& image, bool ta
3838

3939
int test_pokemonSwSh_BoxGenderDetector(const ImageViewRGB32& image, int target);
4040

41+
int test_pokemonSwSh_SelectionArrowFinder(const ImageViewRGB32& image, int target);
42+
4143
}
4244

4345
#endif

SerialPrograms/Source/Tests/TestMap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ const std::map<std::string, TestFunction> TEST_MAP = {
240240
{"PokemonSwSh_BlackDialogBoxDetector", std::bind(image_bool_detector_helper, test_pokemonSwSh_BlackDialogBoxDetector, _1)},
241241
{"PokemonSwSh_BoxShinySymbolDetector", std::bind(image_bool_detector_helper, test_pokemonSwSh_BoxShinySymbolDetector, _1)},
242242
{"PokemonSwSh_BoxGenderDetector", std::bind(image_int_detector_helper, test_pokemonSwSh_BoxGenderDetector, _1)},
243+
{"PokemonSwSh_SelectionArrowFinder", std::bind(image_int_detector_helper, test_pokemonSwSh_SelectionArrowFinder, _1)},
243244
{"PokemonLA_BattleMenuDetector", std::bind(image_bool_detector_helper, test_pokemonLA_BattleMenuDetector, _1)},
244245
{"PokemonLA_BattlePokemonSwitchDetector", std::bind(image_bool_detector_helper, test_pokemonLA_BattlePokemonSwitchDetector, _1)},
245246
{"PokemonLA_TransparentDialogueDetector", std::bind(image_bool_detector_helper, test_pokemonLA_TransparentDialogueDetector, _1)},

0 commit comments

Comments
 (0)