voxl-docker 를 최신버전으로 업데이트하고 문제가 해결됨
swift@swift-HP-Pavilion-dv6-Notebook-PC:~/git/voxl-dfs-server$ voxl-docker -l | grep "voxl"
voxl-cross V1.1 77af6063e492 39 minutes ago 999MB
voxl-cross latest 77af6063e492 39 minutes ago 999MB
voxl-emulator V1.7 55d4f01b7bcd 7 weeks ago 3.33GB
voxl-emulator latest 55d4f01b7bcd 7 weeks ago 3.33GB
voxl-hexagon latest 8509f4e31f56 2 months ago 5.24GB
voxl-emulator V1.5 323601eb49d7 4 months ago 3.2GB
swift@swift-HP-Pavilion-dv6-Notebook-PC:~/git/voxl-dfs-server$
swift@swift-HP-Pavilion-dv6-Notebook-PC:~/git/voxl-dfs-server$ voxl-docker -i voxl-cross
launching image: voxl-cross with the following command:
docker run --rm -it --net=host --privileged -w /home/swift --volume=/dev/bus/usb:/dev/bus/usb -e LOCAL_USER_ID=0 -e LOCAL_USER_NAME=root -e LOCAL_GID=0 -v /home/swift/git/voxl-dfs-server:/home/root:rw -w /home/root voxl-cross /bin/bash -l
voxl-cross:~$ ./install_build_deps.sh stable
using stable repository
Downloading http://voxl-packages.modalai.com/stable/Packages.gz.
Updated source 'stable'.
Installing libmodal_pipe (2.0.7) on root.
Downloading http://voxl-packages.modalai.com/stable/libmodal_pipe_2.0.7.ipk.
Configuring libmodal_pipe.
Done installing libmodal_pipe
Installing libmodal_json (0.3.5) on root.
Downloading http://voxl-packages.modalai.com/stable/libmodal_json_0.3.5.ipk.
Configuring libmodal_json.
Done installing libmodal_json
Installing opencv (4.5.2) on root.
Downloading http://voxl-packages.modalai.com/stable/opencv_4.5.2-1.ipk.
Configuring opencv.
done installing opencv
voxl-cross:~$ ./build.sh
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/root/build_utils/build
Scanning dependencies of target embedfile
[ 50%] Building C object CMakeFiles/embedfile.dir/src/embedfile.c.o
[100%] Linking C executable embedfile
[100%] Built target embedfile
-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc-4.9
-- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc-4.9 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++-4.9
-- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++-4.9 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/root/build64
[ 5%] Generating sobel_filter_kernel_code.c
[ 15%] Generating blur_kernel_code.c
[ 15%] Generating disparity_kernel_code.c
[ 21%] Generating compute_dsi_kernel_code.c
[ 26%] Generating sparse_census_transform_kernel_code.c
Scanning dependencies of target voxl-dfs-server
[ 31%] Building CXX object server/CMakeFiles/voxl-dfs-server.dir/sad_disparity_estimation.cpp.o
[ 36%] Building CXX object server/CMakeFiles/voxl-dfs-server.dir/opencl_manager.cpp.o
[ 42%] Building C object server/CMakeFiles/voxl-dfs-server.dir/undistort.c.o
[ 47%] Building CXX object server/CMakeFiles/voxl-dfs-server.dir/box_filter_blur.cpp.o
[ 52%] Building CXX object server/CMakeFiles/voxl-dfs-server.dir/dfs_processing_engine.cpp.o
[ 57%] Building CXX object server/CMakeFiles/voxl-dfs-server.dir/main.cpp.o
[ 63%] Building CXX object server/CMakeFiles/voxl-dfs-server.dir/opencl_kernel.cpp.o
[ 68%] Building CXX object server/CMakeFiles/voxl-dfs-server.dir/sobel_filter.cpp.o
[ 73%] Building C object server/CMakeFiles/voxl-dfs-server.dir/blur_kernel_code.c.o
[ 78%] Building C object server/CMakeFiles/voxl-dfs-server.dir/disparity_kernel_code.c.o
[ 84%] Building C object server/CMakeFiles/voxl-dfs-server.dir/compute_dsi_kernel_code.c.o
[ 89%] Building C object server/CMakeFiles/voxl-dfs-server.dir/sparse_census_transform_kernel_code.c.o
[ 94%] Building C object server/CMakeFiles/voxl-dfs-server.dir/sobel_filter_kernel_code.c.o
[100%] Linking CXX executable voxl-dfs-server
[100%] Built target voxl-dfs-server
voxl-cross:~$ ./make_package.sh
Package Name: voxl-dfs-server
version Number: 0.2.0
[100%] Built target voxl-dfs-server
Install the project...
-- Install configuration: "Release"
-- Installing: ../ipk/data/etc/systemd/system/voxl-dfs-server.service
-- Installing: ../ipk/data/usr/bin/voxl-dfs-server
/home/root
ar: creating voxl-dfs-server_0.2.0.ipk
DONE
voxl-cross:~$ exit
logout
swift@swift-HP-Pavilion-dv6-Notebook-PC:~/git/voxl-dfs-server$
libpipe 를 최신 버전으로 업데이트함
swift@swift-HP-Pavilion-dv6-Notebook-PC:~/git/libmodal_pipe$ git reset --hard HEAD
HEAD is now at 953bec3 Merge branch 'dev' into 'master'
swift@swift-HP-Pavilion-dv6-Notebook-PC:~/git/libmodal_pipe$ git pull
remote: Enumerating objects: 99, done.
remote: Counting objects: 100% (94/94), done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 68 (delta 51), reused 35 (delta 26), pack-reused 0
Unpacking objects: 100% (68/68), done.
From https://gitlab.com/voxl-public/modal-pipe-architecture/libmodal_pipe
953bec3..0b06bc1 master -> origin/master
fe4372f..6fc8708 dev -> origin/dev
* [new branch] fix-mavlink-includes -> origin/fix-mavlink-includes
* [new branch] james -> origin/james
* [new tag] v2.0.7 -> v2.0.7
Updating 953bec3..0b06bc1
Fast-forward
.gitmodules | 0
CHANGELOG | 36 ++
README.md | 24 +-
android/jni/libmodal_pipe.mk | 10 +-
build_android.sh | 2 +-
examples/modal-hello-client.c | 32 +-
examples/modal-hello-server.c | 55 ++-
examples/modal-hello-sink.c | 16 +-
examples/modal-kill-pipe.c | 8 +-
install_build_deps.sh | 62 +++
ipk/control/control | 4 +-
library/CMakeLists.txt | 11 +-
library/include/modal_pipe_client.h | 185 ++++----
library/include/modal_pipe_common.h | 248 ++++++++++-
library/include/modal_pipe_deprecated.h | 729 ++++++++++++++++++++++++++++++++
library/include/modal_pipe_interfaces.h | 269 +++++++++---
library/include/modal_pipe_server.h | 548 ++++++++++++++----------
library/include/modal_pipe_sink.h | 23 +-
library/include/modal_start_stop.h | 38 --
library/src/client.c | 334 +++++++--------
library/src/common.c | 311 ++++++++++++++
library/src/interfaces.c | 203 ++++++++-
library/src/misc.c | 11 +
library/src/misc.h | 7 +
library/src/server.c | 683 ++++++++++++++++++++----------
library/src/sink.c | 47 +-
library/src/start_stop.c | 113 -----
make_package.sh | 1 +
28 files changed, 2997 insertions(+), 1013 deletions(-)
create mode 100644 .gitmodules
create mode 100755 install_build_deps.sh
create mode 100644 library/include/modal_pipe_deprecated.h
create mode 100644 library/src/common.c
2. 코드분석
카메라 정보 파일 아래 파일 이용
/data/modalai/opencv_stereo_intrinsics.yml
/data/modalai/opencv_stereo_extrinsics.yml
//cal parameter 의미?
stereoRectify( M1, D1, M2, D2, img_size, R, T, R1, R2, P1, P2, Q, CALIB_ZERO_DISPARITY, -1, img_size, &roi1, &roi2 );
initUndistortRectifyMap(M1, D1, R1, P1, img_size, CV_16SC2, map11, map12);
initUndistortRectifyMap(M2, D2, R2, P2, img_size, CV_16SC2, map21, map22);
// pipe server 초기화
if (pipe_server_init_channel(DISPARITY_SCALED_PIPE_CH, DISPARITY_SCALED_PIPE_NAME, 0))
pipe_server_set_default_pipe_size(DISPARITY_SCALED_PIPE_CH, DISPARITY_SCALED_PIPE_DEFAULT_SIZE);
if (pipe_server_init_channel(DISPARITY_FILTERED_PIPE_CH, DISPARITY_FILTERED_PIPE_NAME, 0))
pipe_server_set_default_pipe_size(DISPARITY_FILTERED_PIPE_CH, DISPARITY_FILTERED_PIPE_DEFAULT_SIZE);
if(pipe_server_init_channel(POINT_CLOUD_PIPE_CH, POINT_CLOUD_PIPE_NAME, 0)){
pipe_server_set_default_pipe_size(POINT_CLOUD_PIPE_CH, POINT_CLOUD_PIPE_DEFAULT_SIZE);
// camera server에 client 로 pipe 초기화
pipe_client_set_camera_helper_cb(0, _frame_handler, NULL); // 카메라서버로부터 데이터를 받을때마다 실행되는 함수
pipe_client_set_connect_cb(0, _camera_connect_cb, NULL);
pipe_client_set_disconnect_cb(0, _camera_disconnect_cb, NULL);
structure 구조
camera_image_metadata_t
typedef struct camera_image_metadata_t
{
uint32_t magic_number; ///< set to CAMERA_MAGIC_NUMBER
int64_t timestamp_ns; ///< timestamp in apps-proc clock-monotonic of beginning of exposure
int32_t frame_id; ///< iterator from 0++ starting from first frame when server starts on boot
int16_t width; ///< image width in pixels
int16_t height; ///< image height in bytes
int32_t size_bytes; ///< size of the image, for stereo this is the size of both L&R together
int32_t stride; ///< bytes per row
int32_t exposure_ns; ///< exposure in microseconds
int16_t gain; ///< ISO gain (100, 200, 400, etc..)
int16_t format; ///< raw8, nv12, etc
int32_t reserved;
} __attribute__((packed)) camera_image_metadata_t;
while(1) _frame_handler의 내용
img1_raw, img2_raw // raw image matrix
resize(img1_raw, img1_resized, Size(), 1.0/scale, 1.0/scale, method); // scale =2 이므로 INTER_LINEAR 방법으로 절반으로 스케일링됨
resize(img2_raw, img2_resized, Size(), 1.0/scale, 1.0/scale, method);
remap(img1_resized, img1_rect, map11, map12, INTER_LINEAR); // cal 파일 이용해서 rectified map으로 변경
remap(img2_resized, img2_rect, map21, map22, INTER_LINEAR);
blur(img1_rect, img1_blur, Size(blur_size,blur_size)); // 가우시안 블러링
blur(img2_rect, img2_blur, Size(blur_size,blur_size));
bm->compute(img1_blur, img2_blur, disp_raw); // block matching 방법으로 disparity 계산
wls_filter->filter(disp_raw, img1_rect, disp_filtered, Mat(), wls_roi) // image1과 disparity 영상을 필터처리
disp_filtered.convertTo(disp8, CV_8UC1, 255.0/(disparity_levels *16.0)); // 8bit 영상으로 변환
pipe_server_send_camera_frame_to_channel(DISPARITY_PIPE_CH, disp_meta, (char*)disp8.data); // 8bit 변환 영상을 서버에서 채널로 송출
blob_detector->detect(disp8, keypoints, Mat()); // blop 계산
...
pipe_server_send_point_cloud_to_channel(TARGET_POINT_PIPE_CH, target_pc_meta, target_point) // point cloud의 데이터 송출
imwrite(IMAGE_SAVE_DIR "target_overlay.png", target_overlay); // 오버레이된 이미지 저장
client 에서 사용시
pipe_client_init_channel(OBSTACLE_PIPE_CH, OBSTACLE_PIPE, PIPE_CLIENT_NAME,EN_PIPE_CLIENT_POINT_CLOUD_HELPER, PIPE_READ_BUF_SIZE);
pipe_client_set_point_cloud_helper_cb(OBSTACLE_PIPE_CH, obstacle_pipe_helper_cb, NULL);
'엔지니어링 > 드론' 카테고리의 다른 글
PX4와 Mavlink를 연동하여 시뮬레이션하는 방법 (4) | 2021.08.22 |
---|---|
SWaP-C? (0) | 2021.08.11 |
[ VOXL ] 펌웨어 업데이트(ver 0.4.6) 및 세팅 (0) | 2021.07.01 |
[ VOXL ] 2021.06.12 작업일지 (1) | 2021.06.12 |
[VOXL] voxl-docker opencv-opencl image build (0) | 2021.06.09 |
댓글