Samsung / SamsungAutomationStudio

Samsung Automation Studio is to provide development tools and execution environment that can easily configure application logic by connecting both Samsung service and 3rd party service. This project is to share the node for open source NodeRED developed by Samsung Automation Studio team to the community. If you are using nodered, you can easily install the node we provide. And you can use Samsung's IoT and AI-related services more easily, and you can have an extended experience in conjunction with your own services.
Apache License 2.0
56 stars 29 forks source link

Request to add mediapipe nodes and iotcam2img node #62

Closed wasiwasi closed 1 year ago

wasiwasi commented 1 year ago

안녕하세요. Samsung SW Academy For Youth 7th의 MX사업부 SASM 프로젝트 팀 서부시대입니다.

Samsung Automation Studio for Mashup(이하 SASM)에 Google의 AI 모델 서비스인 Mediapipe를 Wrapping한 노드를 개발해 사용자들이 쉽게 사용할 수 있도록 하고, 그에 필요한 이미지를 얻을 수 있는 iotcam2img 노드를 개발했습니다.

개발한 두 개의 노드와 Samsung SmartThings 기기를 활용할 수 있는 수어 번역 플로우를 제시하였으며, 해당 플로우에는 저희가 직접 학습시킨 모델을 사용했습니다.

저희가 개발한 노드에 대한 설명입니다. (굵게 표시한 부분은 노드입니다.)

노드 파일 설명
iotcam2img Iotcam2img.js IoT 카메라로 부터 받은 rtsp 스트림에서 원하는 프레임만큼 추출하는 노드입니다.
mediapipe main.py mediapipe 처리를 위한 초기화를 담당합니다.
mediapipe_functions.py mediapipe detection, 결과 값 추출을 담당합니다.
mediapipe_controller.py mediapipie start/stop 등 제어를 담당합니다.
requirements.txt 사전에 설치해야 되는 패키지, pip install -r equirements.txt
requestOpen.js Python Mediapipe Open 요청을 전송합니다.
requestClose.js Python Mediapipe Close 요청을 전송합니다.
requestHolistic.js 이미지 Path를 Python으로 전달하고, 그 결과를 받아오도록 요청을 전송합니다.
MediapipeConfig.js open, close, holistic 노드를 여기에 등록, 또한 MediapipeConfig.queue에 node에서 보낸 request를 차례대로 저장합니다.
MediapipeFunctions.js setEventHandler: 데이터 수신(OnListen), 연결 끊어짐(onDisconnect) 상황에서 event handler 등록합니다.
removeEventHandler: setEventHandler에서 등록한 event 제거합니다.
send: MediapipeConfig.queue에서 데이터를 한 개씩 꺼내서 전송. onListen에서 응답 데이터가 수신되어야 다음 데이터를 전송합니다.
onListen: 응답 처리 event handler. 요청 데이터를 보고 적절한 노드로 응답을 보냅니다.(Open, Close, Hollistic Node)
onDisconnect: 연결 끊어짐 처리 event handler. removeEventHandler를 호출하고, MediapipeConfig에 mediapipe가 끊어졌음을 표시합니다.

개발한 노드들과 플로우에 대한 세부 내용은 아래의 링크를 참고해주시기 바랍니다.

iotcam2img mediapipe 훈련된 mediapipe 모델 사용 플로우

프로젝트 기간동안 노드와 플로우를 완성하기까지 부딪혔던 여러 문제들에 대해 같이 고민하며 좋은 방향을 제시해주신 MX사업부 이진규 멘토님과 김선학 멘토님, 그리고 SSAFY 관계자분들께 감사 인사를 드립니다.


Hello. This is the SASM open source project team TeamWildWest from the Samsung SW Academy For Youth 7th.

In the Samsung Automation Studio for Mashup (hereinafter referred to as 'SASM'), We developed a node that wrapped Google's AI model service Mediapipe, making it easy for users to use and creating an iotcam2img node that can obtain the image they need.

We present a sign language translation flow that can utilize the two nodes we developed and Samsung SmartThings devices, and we used a model that we learned ourselves.

Below is a description of the node we developed. (The part marked bold is the node.)

Node Filename Description
iotcam2img Iotcam2img.js A node that extracts as many frames as it wants from the rtsp stream received from the IoT camera.
mediapipe main.py Initialize for mediapipe processing.
mediapipe_functions.py mediapipe detection, Extract mediapipe results.
mediapipe_controller.py Control mediapipie start/stop
requirements.txt Packages that must be pre-installed, pip install -r equirements.txt
requestOpen.js Send request python mediapipe Open
requestClose.js Send request python Mediapipe Close
requestHolistic.js Forward the image path to Python and request to receive the results
MediapipeConfig.js Register open, close, and holistic nodes here, In addition, save requests sent from nodes sequentially in MediapipeConfig.queue
MediapipeFunctions.js setEventHandler: Register event handler in an OnListen, onDisconnect event
removeEventHandler: Remove event handler registered in setEventHandler
send: Take data from MediapipeConfig.queue one at a time and send it. Send the following data, After receiving the response data
onListen: Response event handler. Check the request data and send a response to the appropriate node(Open, Close, Hollistic Node)
onDisconnect: Disconnect event handler. Call the removeEventHandler and indicate that the mediapipe is disconnected in the MediapipeConfig.

Please refer to the link below for details on the nodes and flows.

iotcam2img mediapipe Using trained mediapipe model flow

Special Thanks to Samsung Electronics mentor Jinkyu Lee(@jg8008) and Seonhak Kim(@seonhakkimp) mentor and SSAFY officials who gave us a good direction during the SSDC project.

seunggil1 commented 1 year ago

7주간 많이 배웠습니다. 감사합니다!