Merge 348c42c01b
into f15da632de
This commit is contained in:
commit
aa1e9a829e
|
@ -57,6 +57,8 @@ constexpr char kGrayOutTag[] = "GRAY_OUT";
|
||||||
// RGB -> RGBA
|
// RGB -> RGBA
|
||||||
// RGBA -> BGRA
|
// RGBA -> BGRA
|
||||||
// BGRA -> RGBA
|
// BGRA -> RGBA
|
||||||
|
// RGBA -> GRAY
|
||||||
|
|
||||||
//
|
//
|
||||||
// This calculator only supports a single input stream and output stream at a
|
// This calculator only supports a single input stream and output stream at a
|
||||||
// time. If more than one input stream or output stream is present, the
|
// time. If more than one input stream or output stream is present, the
|
||||||
|
@ -196,6 +198,12 @@ REGISTER_CALCULATOR(ColorConvertCalculator);
|
||||||
cv::COLOR_RGBA2BGRA, cc);
|
cv::COLOR_RGBA2BGRA, cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RGBA -> GRAY
|
||||||
|
if (cc->Inputs().HasTag(kRgbaInTag) && cc->Outputs().HasTag(kGrayOutTag)) {
|
||||||
|
return ConvertAndOutput(kRgbaInTag, kGrayOutTag, ImageFormat::GRAY8,
|
||||||
|
cv::COLOR_RGBA2GRAY, cc);
|
||||||
|
}
|
||||||
|
|
||||||
return ::mediapipe::InvalidArgumentErrorBuilder(MEDIAPIPE_LOC)
|
return ::mediapipe::InvalidArgumentErrorBuilder(MEDIAPIPE_LOC)
|
||||||
<< "Unsupported image format conversion.";
|
<< "Unsupported image format conversion.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,8 @@ inline int GetNextDetectionId() { return ++detection_id; }
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// Assign a unique id to detections.
|
// Assign a unique id to detections.
|
||||||
// Note that the calculator will consume the input vector of Detection or
|
// Note that the calculator will consume or copy the input vector of Detection or
|
||||||
// DetectionList. So the input stream can not be connected to other calculators.
|
// DetectionList.
|
||||||
//
|
//
|
||||||
// Example config:
|
// Example config:
|
||||||
// node {
|
// node {
|
||||||
|
@ -76,7 +76,7 @@ REGISTER_CALCULATOR(DetectionUniqueIdCalculator);
|
||||||
if (cc->Inputs().HasTag(kDetectionListTag) &&
|
if (cc->Inputs().HasTag(kDetectionListTag) &&
|
||||||
!cc->Inputs().Tag(kDetectionListTag).IsEmpty()) {
|
!cc->Inputs().Tag(kDetectionListTag).IsEmpty()) {
|
||||||
auto result =
|
auto result =
|
||||||
cc->Inputs().Tag(kDetectionListTag).Value().Consume<DetectionList>();
|
cc->Inputs().Tag(kDetectionListTag).Value().ConsumeOrCopy<DetectionList>();
|
||||||
if (result.ok()) {
|
if (result.ok()) {
|
||||||
auto detection_list = std::move(result).ValueOrDie();
|
auto detection_list = std::move(result).ValueOrDie();
|
||||||
for (Detection& detection : *detection_list->mutable_detection()) {
|
for (Detection& detection : *detection_list->mutable_detection()) {
|
||||||
|
@ -93,7 +93,7 @@ REGISTER_CALCULATOR(DetectionUniqueIdCalculator);
|
||||||
auto result = cc->Inputs()
|
auto result = cc->Inputs()
|
||||||
.Tag(kDetectionsTag)
|
.Tag(kDetectionsTag)
|
||||||
.Value()
|
.Value()
|
||||||
.Consume<std::vector<Detection>>();
|
.ConsumeOrCopy<std::vector<Detection>>();
|
||||||
if (result.ok()) {
|
if (result.ok()) {
|
||||||
auto detections = std::move(result).ValueOrDie();
|
auto detections = std::move(result).ValueOrDie();
|
||||||
for (Detection& detection : *detections) {
|
for (Detection& detection : *detections) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user