0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

M5UnitV2 & ncnnAdvent Calendar 2023

Day 22

ncnnでUltralight-SimplePoseを動かしてみる

Last updated at Posted at 2023-12-21

概要

ncnnで、Pose推定を行う、Ultralight-SimplePoseを動かしてみる

Screenshot from 2023-11-19 10-05-36.png

環境構築

構築手順に入る前に、まずPCに以下のバージョンのUbuntuをインストールした環境で、構築しました。

M5UnitV2のクロスコンパイル環境を構築する手順

Ubuntu 22.04.3 LTS(x64)
OpenCV ver 0.4.4
ncnn ver 231027

Ultralight-SimplePoseのダウンロード

GitHubからUltralight-SimplePoseのコードをダウンロードします。

$ git clone https://github.com/dog-qiuqiu/Ultralight-SimplePose
$ cd Ultralight-SimplePose/ncnnsample

CMakeLists.txt ファイルの作成

cmakeでコンパイルするために、CMakeLists.txtを作成します。

gedit CMakeLists.txt
CMakeLists.txt

SET(CMAKE_BUILD_TYPE "Release")

SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")

if(TARGET_COMPILER STREQUAL "arm")
    message(STATUS "TARGET_COMPILE STREQUAL arm")
    SET(CMAKE_CXX_COMPILER arm-none-linux-gnueabihf-g++)
    SET(CMAKE_C_COMPILER arm-none-linux-gnueabihf-gcc)
    SET(NCNN_INSTALL_DIR /opt/external/ncnn/install/arm/)
    SET(ZBAR_INSTALL_DIR /opt/external/zbar-0.10/build/arm)
    SET(OpenCV_DIR /opt/external/opencv/build/arm)
else()
    message(STATUS "TARGET_COMPILE STREQUAL X64")
    SET(NCNN_INSTALL_DIR /opt/external/ncnn/install/x64/)
    SET(ZBAR_INSTALL_DIR /opt/external/zbar-0.10/build/x64/)
    SET(OpenCV_DIR /opt/external/opencv/build/x64) 
endif()


PROJECT(ncnnpose)
cmake_minimum_required(VERSION 3.5)

if(OpenCV_FOUND)
 message(OPENCV_VERSION)
endif(OpenCV_FOUND)

find_package(OpenCV REQUIRED)

link_directories(${OpenCV_LIBRARY_DIRS})

include_directories(${OpenCV_INCLUDE_DIRS} )
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${NCNN_INSTALL_DIR}/include/ncnn)

add_executable(ncnnpose ncnnpose.cpp)
target_link_libraries(ncnnpose ${OpenCV_LIBRARIES})
target_link_libraries(ncnnpose ${NCNN_INSTALL_DIR}/lib/libncnn.a -fopenmp)

ビルド

プログラムをコンパイルして実行します。

$ cmake .
$ make
$ ./ncnnpose

プログラムの格納先

このプログラムは以下に格納しています。

参考資料

この記事を作成するにあたり、以下のウェブサイトを参考にしました。

dog-qiuqiu/Ultralight-SimplePose

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?