Skip to content

Commit 9e42ecb

Browse files
committed
Fix ArcPhoneDetector.
1 parent 24a2a8b commit 9e42ecb

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

SerialPrograms/Source/Kernels/Waterfill/Kernels_Waterfill_Types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
#include <stddef.h>
1111
#include <stdint.h>
12-
//#include <map>
13-
//#include <iostream>
1412
#include "Common/Cpp/Rectangle.h"
1513
#include "Kernels/BinaryMatrix/Kernels_BinaryMatrix.h"
1614

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Common/Cpp/Concurrency/AsyncDispatcher.h"
1616
#include "Common/Cpp/Concurrency/PeriodicScheduler.h"
1717
#include "CommonFramework/Exceptions/OperationFailedException.h"
18+
#include "CommonTools/Async/InferenceRoutines.h"
1819
#include "CommonTools/OCR/OCR_RawOCR.h"
1920
#include "PokemonLA/Inference/PokemonLA_MountDetector.h"
2021
#include "Pokemon/Pokemon_Strings.h"
@@ -302,8 +303,8 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
302303
using namespace Pokemon;
303304
using namespace PokemonSwSh;
304305
// using namespace PokemonBDSP;
305-
// using namespace PokemonLA;
306-
using namespace PokemonSV;
306+
using namespace PokemonLA;
307+
// using namespace PokemonSV;
307308

308309
[[maybe_unused]] Logger& logger = env.logger();
309310
[[maybe_unused]] ConsoleHandle& console = env.consoles[0];
@@ -315,7 +316,25 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
315316

316317
// std::terminate();
317318

318-
#if 1
319+
320+
ImageRGB32 image("20250404-154507236508.png");
321+
322+
ArcPhoneDetector phone(logger, overlay, std::chrono::milliseconds(250), true);
323+
324+
while (true){
325+
cout << phone.process_frame(image, current_time()) << endl;
326+
scope.wait_for(100ms);
327+
}
328+
329+
#if 0
330+
wait_until(
331+
console, context,
332+
10000ms,
333+
{phone}
334+
);
335+
#endif
336+
337+
#if 0
319338
// ImageRGB32 image(IMAGE_PATH);
320339
auto image = feed.snapshot();
321340

SerialPrograms/Source/PokemonLA/Inference/Objects/PokemonLA_ArcPhoneDetector.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ ArcPhoneTracker::ArcPhoneTracker()
3737
Color(0xff909090),
3838
Color(0xffa0a0a0),
3939
Color(0xffb0b0b0),
40+
Color(0xffc0c0c0),
41+
Color(0xffd0d0d0),
42+
Color(0xffe0e0e0),
43+
Color(0xfff0f0f0),
4044
}
4145
)
4246
{}
@@ -45,9 +49,9 @@ void ArcPhoneTracker::process_object(const ImageViewRGB32& image, const Waterfil
4549
// cout << "asdf" << endl;
4650
// static int c = 0;
4751
// cout << "c = " << c << endl;
48-
// extract_box_reference(image, object).save("test-" + std::to_string(c++) + ".png");
52+
// extract_box_reference(image, object).save("testA-" + std::to_string(c++) + ".png");
4953
// image.save("test-" + std::to_string(c++) + "-A.png");
50-
// extract_box(image, object).save("test-" + std::to_string(c++) + "-B.png");
54+
// extract_box_reference(image, object).save("testB-" + std::to_string(c++) + ".png");
5155

5256
double width = (double)object.width() / image.width();
5357
if (width < 0.40 || width > 0.50){
@@ -65,6 +69,8 @@ void ArcPhoneTracker::process_object(const ImageViewRGB32& image, const Waterfil
6569
}
6670
}
6771
void ArcPhoneTracker::finish(const ImageViewRGB32& image){
72+
// static int count = 0;
73+
// image.save("test0-" + std::to_string(count++) + ".png");
6874
merge_heavily_overlapping();
6975
}
7076

@@ -114,9 +120,12 @@ void ArcPhoneDetector::make_overlays(VideoOverlaySet& items) const{
114120
}
115121
bool ArcPhoneDetector::process_frame(const ImageViewRGB32& frame, WallClock timestamp){
116122
m_watcher.process_frame(frame, timestamp);
123+
// cout << "White Objects = " << m_tracker_phone.detections().size() << endl;
117124
bool detected0 = m_debouncer_phone.push_value(!m_tracker_phone.detections().empty(), timestamp);
118125
bool detected1 = m_debouncer_button.push_value(!m_tracker_phone.detections().empty(), timestamp);
119126

127+
// cout << detected0 << ", " << detected1 << endl;
128+
120129
#if 0
121130
if (detected){
122131
static size_t c = 0;

SerialPrograms/Source/PokemonLA/Inference/Objects/PokemonLA_WhiteObjectDetector.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ void find_overworld_white_objects(
3737
// }
3838
// compress_rgb32_to_binary_range(image, filters.data(), filters.size());
3939

40+
// static int count = 0;
4041
{
4142
std::vector<std::pair<uint32_t, uint32_t>> filters;
4243
for (Color filter : threshold_set){
@@ -47,13 +48,17 @@ void find_overworld_white_objects(
4748
#if 1
4849
std::unique_ptr<WaterfillSession> session = make_WaterfillSession();
4950
for (size_t c = 0; c < filters.size(); c++){
51+
52+
// cout << "filter[" << c << "] = " << filters[c].first << endl;
5053
// cout << matrix[c].width() << " x " << matrix[c].height() << endl;
5154
// cout << matrix[c].dump() << endl;
5255
session->set_source(matrix[c]);
5356
auto finder = session->make_iterator(50);
5457
WaterfillObject object;
5558
while (finder->find_next(object, false)){
5659
// cout << object.area << endl;
60+
// cout << matrix[c].submatrix(object.min_x, object.min_y, object.width(), object.height()).dump() << endl;
61+
// extract_box_reference(image, object).save("test-" + std::to_string(count++) + "-" + std::to_string(c) + ".png");
5762
for (const auto& detector : detectors){
5863
const std::set<Color>& thresholds = detector.first.thresholds();
5964
if (thresholds.find((Color)filters[c].first) != thresholds.end()){

0 commit comments

Comments
 (0)