Fixed issues in MPPObjectDetector
This commit is contained in:
parent
11413f0acd
commit
1c0e17ea17
|
@ -25,6 +25,7 @@
|
||||||
namespace {
|
namespace {
|
||||||
using ::mediapipe::NormalizedRect;
|
using ::mediapipe::NormalizedRect;
|
||||||
using ::mediapipe::Packet;
|
using ::mediapipe::Packet;
|
||||||
|
using ::mediapipe::Timestamp;
|
||||||
using ::mediapipe::tasks::core::PacketMap;
|
using ::mediapipe::tasks::core::PacketMap;
|
||||||
using ::mediapipe::tasks::core::PacketsCallback;
|
using ::mediapipe::tasks::core::PacketsCallback;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -80,13 +81,22 @@ static NSString *const kTaskGraphName = @"mediapipe.tasks.vision.ObjectDetectorG
|
||||||
if (options.completion) {
|
if (options.completion) {
|
||||||
packetsCallback = [=](absl::StatusOr<PacketMap> status_or_packets) {
|
packetsCallback = [=](absl::StatusOr<PacketMap> status_or_packets) {
|
||||||
NSError *callbackError = nil;
|
NSError *callbackError = nil;
|
||||||
MPPObjectDetectionResult *result;
|
if (![MPPCommonUtils checkCppError:status_or_packets.status() toError:&callbackError]) {
|
||||||
if ([MPPCommonUtils checkCppError:status_or_packets.status() toError:&callbackError]) {
|
options.completion(nil, Timestamp::Unset().Value(), callbackError);
|
||||||
result = [MPPObjectDetectionResult
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketMap &outputPacketMap = status_or_packets.value();
|
||||||
|
if (outputPacketMap[kImageOutStreamName.cppString].IsEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MPPObjectDetectionResult *result = [MPPObjectDetectionResult
|
||||||
objectDetectionResultWithDetectionsPacket:status_or_packets.value()
|
objectDetectionResultWithDetectionsPacket:status_or_packets.value()
|
||||||
[kDetectionsStreamName.cppString]];
|
[kDetectionsStreamName.cppString]];
|
||||||
}
|
|
||||||
options.completion(result, callbackError);
|
options.completion(result, outputPacketMap[kImageOutStreamName.cppString].Timestamp().Value() /
|
||||||
|
kMicroSecondsPerMilliSecond, callbackError);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +121,7 @@ static NSString *const kTaskGraphName = @"mediapipe.tasks.vision.ObjectDetectorG
|
||||||
return [self initWithOptions:options error:error];
|
return [self initWithOptions:options error:error];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (nullable MPPObjectDetectionResult *)detectINImage:(MPPImage *)image
|
- (nullable MPPObjectDetectionResult *)detectInImage:(MPPImage *)image
|
||||||
regionOfInterest:(CGRect)roi
|
regionOfInterest:(CGRect)roi
|
||||||
error:(NSError **)error {
|
error:(NSError **)error {
|
||||||
std::optional<NormalizedRect> rect =
|
std::optional<NormalizedRect> rect =
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
static const int kMicroSecondsPerMilliSecond = 1000;
|
||||||
|
|
||||||
@interface MPPObjectDetectionResult (Helpers)
|
@interface MPPObjectDetectionResult (Helpers)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
#import "mediapipe/tasks/ios/components/containers/utils/sources/MPPDetection+Helpers.h"
|
#import "mediapipe/tasks/ios/components/containers/utils/sources/MPPDetection+Helpers.h"
|
||||||
|
|
||||||
static const int kMicroSecondsPerMilliSecond = 1000;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
using DetectionProto = ::mediapipe::Detection;
|
using DetectionProto = ::mediapipe::Detection;
|
||||||
using ::mediapipe::Packet;
|
using ::mediapipe::Packet;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user