<jupyter_start><jupyter_text>Pose Detection with OpenPoseThis notebook uses an open source project [CMU-Perceptual-Computing-Lab/openpose](https://github.com/CMU-Perceptual-Computing-Lab/openpose.git) to detect/track multi person poses on a video from your Google Drive@dinatih update base on https://colab.research.google.com/github/tugstugi/dl-colab-notebooks/blob/master/notebooks/OpenPose.ipynb  Choose a video from your Google Drive<jupyter_code>from google.colab import drive
drive.mount('/content/drive')<jupyter_output>Mounted at /content/drive<jupyter_text>Install OpenPose on Google Colab<jupyter_code>import os
from os.path import exists, join, basename, splitext

git_repo_url = 'https://github.com/CMU-Perceptual-Computing-Lab/openpose.git'
# git_repo_url = 'https://github.com/dinatih/openpose.git'
project_name = splitext(basename(git_repo_url))[0]

if 1 or not exists(project_name):
  !rm -rf openpose
  # see: https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/949

  print("install new CMake becaue of CUDA10")
  if not exists('cmake-3.13.0-Linux-x86_64.tar.gz'):
    !wget -q https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz
  !tar xfz cmake-3.13.0-Linux-x86_64.tar.gz --strip-components=1 -C /usr/local

  print("clone openpose")
  !git clone -q --depth 1 $git_repo_url
  print("CMakelist.txt's caffe fix")
  !sed -i 's/execute_process(COMMAND git checkout master WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\/3rdparty\/caffe)/execute_process(COMMAND git checkout f019d0dfe86f49d1140961f8c7dec22130c83154 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\/3rdparty\/caffe)/g' openpose/CMakeLists.txt
  print("install system dependencies")
  !apt-get -qq install -y libatlas-base-dev libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libgflags-dev libgoogle-glog-dev liblmdb-dev opencl-headers ocl-icd-opencl-dev libviennacl-dev
  print("build openpose")
  !cd openpose && rm -rf build || true && mkdir build && cd build && cmake .. && make -j`nproc`<jupyter_output>install new CMake becaue of CUDA10
clone openpose
CMakelist.txt's caffe fix
install system dependencies
Selecting previously unselected package libgflags2.2.
(Reading database ... 160975 files and directories currently installed.)
Preparing to unpack .../00-libgflags2.2_2.2.1-1_amd64.deb ...
Unpacking libgflags2.2 (2.2.1-1) ...
Selecting previously unselected package libgflags-dev.
Preparing to unpack .../01-libgflags-dev_2.2.1-1_amd64.deb ...
Unpacking libgflags-dev (2.2.1-1) ...
Selecting previously unselected package libgoogle-glog0v5.
Preparing to unpack .../02-libgoogle-glog0v5_0.3.5-1_amd64.deb ...
Unpacking libgoogle-glog0v5 (0.3.5-1) ...
Selecting previously unselected package libgoogle-glog-dev.
Preparing to unpack .../03-libgoogle-glog-dev_0.3.5-1_amd64.deb ...
Unpacking libgoogle-glog-dev (0.3.5-1) ...
Selecting previously unselected package libhdf5-serial-dev.
Preparing to unpack .../04-libhdf5-serial-dev_1.10.0-patch1+docs-4_all.deb ...
Unpacking libhdf5-serial-dev (1.10.0[...]<jupyter_text>From a Google Drive's folder<jupyter_code>import os
from os.path import exists, join, basename, splitext

folder_path = '/content/drive/MyDrive/Colab Notebooks/deskdata/open_image'
files = os.listdir(folder_path)
files.reverse()
for filename in files:
  if filename.endswith('.PNG') and not filename.endswith('-openpose.png'):
    print(filename)
    colab_video_path = folder_path + filename
    print(colab_video_path)
    colab_openpose_video_path = colab_video_path.replace('.png', '') + '-openpose.png'
    print(colab_openpose_video_path)
    if not exists(colab_openpose_video_path):
      !cd openpose && ./build/examples/openpose/openpose.bin --hand --face --number_people_max 12 --video '{colab_video_path}' --display 0 --write_video_with_audio --write_video '{colab_openpose_video_path}' # --net_resolution "-1x736" --scale_number 4 --scale_gap 0.25<jupyter_output>cap.PNG
/content/drive/MyDrive/Colab Notebooks/deskdata/open_imagecap.PNG
/content/drive/MyDrive/Colab Notebooks/deskdata/open_imagecap.PNG-openpose.png
Starting OpenPose demo...
Configuring OpenPose...
Starting thread(s)...

Error:
VideoCapture (IP camera/video) could not be opened for path: '/content/drive/MyDrive/Colab Notebooks/deskdata/open_imagecap.PNG'. If it is a video path, is the path correct?

Coming from:
- /content/openpose/src/openpose/producer/videoCaptureReader.cpp:VideoCaptureReader():54
- /content/openpose/src/openpose/producer/videoCaptureReader.cpp:VideoCaptureReader():58
- /content/openpose/src/openpose/producer/producer.cpp:createProducer():475
- /content/openpose/include/openpose/wrapper/wrapperAuxiliary.hpp:configureThreadManager():1221
- /content/openpose/include/openpose/wrapper/wrapper.hpp:exec():424<jupyter_text>Run OpenPose<jupyter_code># video_folder = os.path.dirname(colab_video_path)
# video_base_name = os.path.basename(colab_video_path)
# print(video_base_name)
import os
from os.path import exists, join, basename, splitext


colab_video_path = '/content/drive/MyDrive/Colab Notebooks/deskdata/open_image/cap.PNG'




colab_openpose_video_path = colab_video_path.replace('.png', '') + '-openpose.png'

colab_json_path= '/content/drive/MyDrive/Colab Notebooks/deskdata/open_image'

!cd openpose && ./build/examples/openpose/openpose.bin --number_people_max 12 --video '{colab_video_path}' --display 0  --write_video '{colab_openpose_video_path}' # --net_resolution "-1x736" --scale_number 4 --scale_gap 0.25
!cd openpose && ./build/examples/openpose/openpose.bin --video  '{colab_video_path}'  --render_pose 0 --display 0 --number_people_max=2 --write_json '{colab_json_path}'

!find  '/content/drive/MyDrive/Colab Notebooks/deskdata/open_image'  -name "*.json" -exec cp {} .  \;

#끝나고 rm 하기 (그럼 계속 하나의 json파일만 가져올수있음)


#!cd openpose && ./build/examples/openpose/openpose.bin --video  '{colab_video_path}'  --render_pose 0 --display 0 --number_people_max=2 --write_json '{colab_json_path}'
#!cd openpose && ./build/examples/openpose/openpose.bin --video $root_path/$file_path" "--render_pose 0 --display 0 --number_people_max=2 --write_json "$output_path"



!cp -r   colab_video_path.replace('.json', '') + '-openpose.json' . 

read_key= os.path.basename(colab_json_path)<jupyter_output>/bin/bash: -c: line 0: syntax error near unexpected token `('
/bin/bash: -c: line 0: `cp -r   colab_video_path.replace('.json', '') + '-openpose.json' . '
{'fraction_non_alphanumeric': 0.1346333853354134, 'fraction_numerical': 0.030577223088923557, 'mean_word_length': 4.807065217391305, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '121445', 'license': 'MIT', 'n_tokens_mistral': 2470, 'n_tokens_neox': 2324, 'n_words': 439, 'path': 'algorithm/OpenPose_frametest.ipynb', 'repo_name': 'btothey99/DibidibidipLearning', 'size': '6410'}