Project import generated by Copybara.

PiperOrigin-RevId: 255500495
This commit is contained in:
MediaPipe Team
2019-06-27 17:10:09 -07:00
committed by jqtang
parent 2aaf4693db
commit 56cdbaf140
12 changed files with 86 additions and 41 deletions
@@ -216,6 +216,9 @@ REGISTER_CALCULATOR(RecolorCalculator);
GlRender();
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
glFlush();
}
@@ -321,13 +321,20 @@ REGISTER_CALCULATOR(SetAlphaCalculator);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, alpha_texture.name());
GlRender(cc); // use channel 0 of mask
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
alpha_texture.Release();
} else {
gpu_helper_.BindFramebuffer(output_texture); // GL_TEXTURE0
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, input_texture.name());
GlRender(cc); // use value from options
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
}
glFlush();
// Send out image as GPU packet.
auto output_frame = output_texture.GetFrame<mediapipe::GpuBuffer>();
@@ -393,9 +400,6 @@ REGISTER_CALCULATOR(SetAlphaCalculator);
glDeleteVertexArrays(1, &vao);
glDeleteBuffers(2, vbo);
// execute command queue
glBindTexture(GL_TEXTURE_2D, 0);
glFlush();
#endif // __ANDROID__
return ::mediapipe::OkStatus();
@@ -506,8 +506,7 @@ Detection TfLiteTensorsToDetectionsCalculator::ConvertToDetection(
#if defined(__ANDROID__)
// A shader to decode detection boxes.
const std::string decode_src = absl::Substitute(
R"(
#version 310 es
R"( #version 310 es
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
@@ -643,8 +642,7 @@ void main() {
// A shader to score detection boxes.
const std::string score_src = absl::Substitute(
R"(
#version 310 es
R"( #version 310 es
layout(local_size_x = 1, local_size_y = $0, local_size_z = 1) in;
@@ -301,6 +301,8 @@ REGISTER_CALCULATOR(TfLiteTensorsToSegmentationCalculator);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, input_mask_texture.name());
mask_program_with_prev_->Dispatch(workgroups);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
}
}
@@ -413,8 +415,7 @@ void TfLiteTensorsToSegmentationCalculator::GlRender() {
// Currently uses 4 channels for output,
// and sets both R and A channels as mask value.
const std::string shader_src_template =
R"(
#version 310 es
R"( #version 310 es
layout(local_size_x = $0, local_size_y = $0, local_size_z = 1) in;
@@ -359,6 +359,9 @@ REGISTER_CALCULATOR(AnnotationOverlayCalculator);
RETURN_IF_ERROR(GlRender(cc));
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
glFlush();
}