This is the two related method:

absl::Status Open(CalculatorContext* cc) override {
        ...
        
        return gpu_helper_.RunInGlContext([&]() -> absl::Status {

           const auto& options = cc->Options<FaceGeometryEffectRendererCalculatorOptions>();
            
           // If i replace 
           //     ASSIGN_OR_RETURN(ImageFrame effect_texture, ReadTextureFromFile(options._path()),_ << "Failed ");               
           // using 
           //     ASSIGN_OR_RETURN(ImageFrame effect_texture, ReadTextureFromFile("mediapipe/graphs/face_effect/data:ic_cube_maps_left.pngblob"),_ << "Failed");
           //
           // it will report error:
           // "A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 22251 (mediapipe_gl_ru), pid 21862 (apps.faceeffect)" 
           // 
           // 'ASSIGN_OR_RETURN()' defined here https://github.com/google/mediapipe/blob/ecb5b5f44ab23ea620ef97a479407c699e424aa7/mediapipe/framework/port/status_macros.h 
           
           ASSIGN_OR_RETURN(ImageFrame effect_texture, ReadTextureFromFile(options._path()), _ << "Failed ");
           
           // This line print "mediapipe/graphs/face_effect/data:ic_cube_maps_left.pngblob", this is the main param of above method.
           LOG(INFO) << options.effect_texture_path();  

           ... 
           return absl::OkStatus();
    });
  }




static absl::StatusOr<ImageFrame> ReadTextureFromFile(const std::string& texture_path) {
    ... 
    cv::Mat output_mat;
    switch (decoded_mat.channels()) {
      case 3:
        image_format = ImageFormat::SRGB;
        cv::cvtColor(input_mat, output_mat, cv::COLOR_BGR2RGB);
        break;

      case 4:
        image_format = ImageFormat::SRGBA;
        cv::cvtColor(input_mat, output_mat, cv::COLOR_BGRA2RGBA);
        break;
    }

    ImageFrame output_image_frame(image_format, output_mat.size().width,
                                  output_mat.size().height,
                                  ImageFrame::kGlDefaultAlignmentBoundary);
    output_mat.copyTo(formats::MatView(&output_image_frame));
    
    // This line works fine ,it print 4096. 
    // Even if after replacing
    //     ASSIGN_OR_RETURN(ImageFrame effect_texture, ReadTextureFromFile(options._path()),_ << "Failed ");               
    // using 
    //     ASSIGN_OR_RETURN(ImageFrame effect_texture, ReadTextureFromFile("mediapipe/graphs/face_effect/data:ic_cube_maps_left.pngblob"),_ << "Failed");
   // this is still can print 4096.

    LOG(INFO) << "output_image_frame.Width() " << output_image_frame.Width() ;  
    return output_image_frame;
  }

I just replace options._path() using "mediapipe/graphs/face_effect/data:ic_cube_maps_left.pngblob" when invoke ReadTextureFromFile() , then i got this error A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 22251 (mediapipe_gl_ru), pid 21862 (apps.faceeffect). it's a little wired.

Method options._path(), it return path_.Get() , and the type of path_ is ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr .

I add most explanation in the code comments. it seems more directly.

Reference project : https://github.com/google/mediapipe

0

There are 0 answers