작동하는 버전의 MediaPipe 프레임워크가 있는지 확인합니다. 설치 안내를 참조하세요.
hello world
예를 실행하려면 다음 안내를 따르세요.$ git clone https://github.com/google/mediapipe.git $ cd mediapipe $ export GLOG_logtostderr=1 # Need bazel flag 'MEDIAPIPE_DISABLE_GPU=1' as desktop GPU is not supported currently. $ bazel run --define MEDIAPIPE_DISABLE_GPU=1 \ mediapipe/examples/desktop/hello_world:hello_world # It should print 10 rows of Hello World! # Hello World! # Hello World! # Hello World! # Hello World! # Hello World! # Hello World! # Hello World! # Hello World! # Hello World! # Hello World!
hello world
예에서는CalculatorGraphConfig
proto에 정의된PrintHelloWorld()
함수에 간단한 MediaPipe 그래프를 사용합니다.absl::Status PrintHelloWorld() { // Configures a simple graph, which concatenates 2 PassThroughCalculators. CalculatorGraphConfig config = ParseTextProtoOrDie<CalculatorGraphConfig>(R"( input_stream: "in" output_stream: "out" node { calculator: "PassThroughCalculator" input_stream: "in" output_stream: "out1" } node { calculator: "PassThroughCalculator" input_stream: "out1" output_stream: "out" } )");
아래의 CalculatorGraphConfig 콘텐츠를 비주얼라이저에 붙여넣어 MediaPipe Visualizer로 이 그래프를 시각화할 수 있습니다. 비주얼라이저에 관한 도움말은 여기를 참고하세요.
input_stream: "in" output_stream: "out" node { calculator: "PassThroughCalculator" input_stream: "in" output_stream: "out1" } node { calculator: "PassThroughCalculator" input_stream: "out1" output_stream: "out" }
이 그래프는 그래프 입력 스트림 1개 (
in
)와 그래프 출력 스트림 1개(out
), 직렬로 연결된 2개의PassThroughCalculator
로 구성됩니다.그래프를 실행하기 전에 나중에 그래프 출력을 검색하기 위해
OutputStreamPoller
객체를 출력 스트림에 연결하고 그래프 실행이StartRun
로 시작됩니다.CalculatorGraph graph; MP_RETURN_IF_ERROR(graph.Initialize(config)); MP_ASSIGN_OR_RETURN(OutputStreamPoller poller, graph.AddOutputStreamPoller("out")); MP_RETURN_IF_ERROR(graph.StartRun({}));
그런 다음
MakePacket
함수를 사용하여 각 패킷에 0, 1, ... 9 사이의 타임스탬프 값을 가진 'Hello World!' 문자열을 포함한 패킷 10개를 만들고in
입력 스트림을 통해 각 패킷을 그래프에 추가한 후 마지막으로 입력 스트림을 닫아 그래프 실행을 완료합니다.for (int i = 0; i < 10; ++i) { MP_RETURN_IF_ERROR(graph.AddPacketToInputStream("in", MakePacket<std::string>("Hello World!").At(Timestamp(i)))); } MP_RETURN_IF_ERROR(graph.CloseInputStream("in"));
그런 다음 예는
OutputStreamPoller
객체를 통해 출력 스트림에서 10개의 패킷을 모두 검색하고 각 패킷에서 문자열 콘텐츠를 가져와 출력 로그에 출력합니다.mediapipe::Packet packet; while (poller.Next(&packet)) { LOG(INFO) << packet.Get<string>(); }
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-05-14(UTC)
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"필요한 정보가 없음"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"너무 복잡함/단계 수가 너무 많음"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"오래됨"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"번역 문제"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"샘플/코드 문제"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"기타"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"이해하기 쉬움"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"문제가 해결됨"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"기타"
}]