您好,登錄后才能下訂單哦!
如何進行OpenNI-Linux-Arm64-2.3.0.66安裝與調試,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
最近在研究某攝像頭,通過USB插入到Arm64的板子上進行安裝調試,這里嘗試著把過程記錄下來。
從官網上下載相應系統和版本的SDK,我這里是Linux-ARM64版本的,下載的是 OpenNI-Linux-Arm64-2.3.0.66 。或者wget鏈接地址
proxychains4 wget https://abzg-oss.oss-cn-shenzhen.aliyuncs.com/files/OpenNI-Linux-Arm64-2.3.0.66.zip [proxychains] config file found: /etc/proxychains.conf [proxychains] preloading /usr/local/lib/libproxychains4.so [proxychains] DLL init: proxychains-ng 4.14 --2021-02-08 20:57:26-- https://abzg-oss.oss-cn-shenzhen.aliyuncs.com/files/OpenNI-Linux-Arm64-2.3.0.66.zip 正在解析主機 abzg-oss.oss-cn-shenzhen.aliyuncs.com (abzg-oss.oss-cn-shenzhen.aliyuncs.com)... 224.0.0.1 正在連接 abzg-oss.oss-cn-shenzhen.aliyuncs.com (abzg-oss.oss-cn-shenzhen.aliyuncs.com)|224.0.0.1|:443... [proxychains] Strict chain ... 172.18.6.135:8001 ... abzg-oss.oss-cn-shenzhen.aliyuncs.com:443 ... OK 已連接。 已發出 HTTP 請求,正在等待回應... 200 OK 長度: 3758034 (3.6M) [application/zip] 正在保存至: “OpenNI-Linux-Arm64-2.3.0.66.zip” OpenNI-Linux-Arm64-2.3.0.66.zip 100% [===================================>] 3.58M 7.57MB/s in 0.5s 2021-02-08 20:57:27 (7.57 MB/s) - 已保存 “OpenNI-Linux-Arm64-2.3.0.66.zip” [3758034/3758034])
解壓,目錄結構如下
-rw-rw-r-- 1 work work 9753 Sep 29 16:54 CHANGES.txt -rw-rw-r-- 1 work work 11358 Sep 29 16:54 LICENSE -rw-rw-r-- 1 work work 31653 Sep 29 16:54 NOTICE -rw-rw-r-- 1 work work 5615 Sep 29 16:54 README drwxrwxr-x 3 work work 4096 Jan 12 15:52 Redist -rw-rw-r-- 1 work work 1863 Sep 29 16:54 ReleaseNotes.txt drwxrwxr-x 12 work work 4096 Jan 12 15:52 Samples drwxrwxr-x 3 work work 4096 Jan 12 15:52 Tools drwxrwxr-x 8 work work 4096 Jan 12 15:52 include -rw-rw-r-- 1 work work 2138 Mar 10 2020 install.sh -rw-rw-r-- 1 work work 1221 Sep 29 16:54 orbbec-usb.rules
閱讀README文件,其中
0 OpenNI-Linux-Arm64-2.3.0.66 > cat README OpenNI ------ Website: http://structure.io/openni Building Prerequisites ====================== ... Linux ----- - GCC 4.x From: http://gcc.gnu.org/releases.html Or via apt: sudo apt-get install g++ - Python 2.6+/3.x From: http://www.python.org/download/ Or via apt: sudo apt-get install python - LibUSB 1.0.x From: http://sourceforge.net/projects/libusb/files/libusb-1.0/ Or via apt: sudo apt-get install libusb-1.0-0-dev - LibUDEV sudo apt-get install libudev-dev - JDK 6.0 From: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u32-downloads-1594644.html Or via apt: sudo apt-get install openjdk-6-jdk - FreeGLUT3 From: http://freeglut.sourceforge.net/index.php#download Or via apt: sudo apt-get install freeglut3-dev - Doxygen From: http://www.stack.nl/~dimitri/doxygen/download.html#latestsrc Or via apt: sudo apt-get install doxygen - GraphViz From: http://www.graphviz.org/Download_linux_ubuntu.php Or via apt: sudo apt-get install graphviz ... Building ======== Building on Windows: Open the solution OpenNI.sln Building on Linux / OS X: Run: $ make Cross-Compiling for ARM on Linux: The following environment variables should be defined: - ARM_CXX=<path to cross-compilation g++> - ARM_STAGING=<path to cross-compilation staging dir> Then, run: $ PLATFORM=Arm make Building for Android: - Create a workspace in eclipse - Import all projects under root directory Creating OpenNI2 Package ======================== - Go into the directory 'Packaging' - Run ReleaseVersion.py [x86|x64|Arm|Android] - Installer will be placed in the 'Final' directory Building in an armhf qemu-enabled docker container ================================================== - Note: we're building from the osrf fork which has a couple of minor tweaks compared to the orbbec upstream repo (https://github.com/orbbec/OpenNI2/compare/orbbec-dev...osrf:orbbec-dev?expand=1): - don't force soft-float in third-party software (because we're building with hard-float) - disable documentation generation (because we don't need it, and also because doxygen seems to just hang in this environment). - Check out the code (because git doesn't work inside qemu): $ git clone https://github.com/osrf/OpenNI2 $ cd OpenNI2 $ git checkout orbbec-dev $ cd .. - Start docker, mounting in the git repo: $ docker run -ti -v `pwd`/OpenNI2:/tmp/OpenNI2 osrf/ubuntu_armhf:trusty bash - Now inside docker, install prereqs (we're removing udev because it somehow conflicts with libudev-dev; we're leaving out doxygen and graphviz because we're not going to build docs): # apt-get update # apt-get remove -y --force-yes udev # apt-get install -y build-essential python libusb-1.0-0-dev libudev-dev openjdk-6-jdk freeglut3-dev - Still inside docker, build the release package (note that, instead of running `ReleaseVersion.py` inside `Packaging`, you could just run `make HAS_JAVA=1 release` at the top level): # cd /tmp/OpenNI2/Packaging # ./ReleaseVersion.py Arm - If all goes well, there will be a file in the docker container called something like `/tmp/OpenNI2/Packaging/Final/OpenNI-Linux-Arm-2.3.tar.bz2`. It's also in the corresponding place in the host filesystem, so it will survive exiting the container. That file contains the compiled libraries (importantly, `OpenNI-Linux-Arm-2.3/Redist/libOpenNI2.so`).
這里指明了一些軟件運行所需的依賴和安裝方法,這里就不再贅述。后續的 building 等不是必須的操作。
在解壓后的目錄中,執行 install.sh 文件
sudo sh install.sh
該腳本一共做了兩件事,為攝像頭設備增加UDEV規則,把開發環境寫到 OpenNIDevEnvironment
文件中。
cat OpenNIDevEnvironment export OPENNI2_INCLUDE=/home/work/abc/OpenNI-Linux-Arm64-2.3.0.65/Include export OPENNI2_REDIST=/home/work/abc/OpenNI-Linux-Arm64-2.3.0.65/Redist
注意第一個環境變量的Include,實際的目錄名稱為 include,記得改過來(要么把目錄名稱改成大寫,要么把環境變量改成小寫,我這里是選擇改環境變量。)
然后再進行加載使其生效。
source OpenNIDevEnvironment
檢查一下
env | grep OPENNI2_INCLUDE OPENNI2_INCLUDE=/home/work/abc/OpenNI-Linux-Arm64-2.3.0.66/include
在Samples目錄下,我們可以看到很多樣例
drwxrwxr-x 3 work work 4096 Jan 20 22:10 Bin drwxrwxr-x 2 work work 4096 Jan 20 22:10 ClosestPointViewer drwxrwxr-x 2 work work 4096 Jan 20 22:10 EventBasedRead drwxrwxr-x 2 work work 4096 Jan 20 22:10 MWClosestPoint drwxrwxr-x 2 work work 4096 Jan 20 22:10 MWClosestPointApp drwxrwxr-x 2 work work 4096 Jan 20 22:10 MultiDepthViewer drwxrwxr-x 3 work work 4096 Feb 8 17:28 MultipleStreamRead drwxrwxr-x 3 work work 4096 Jan 21 20:06 SimpleRead drwxrwxr-x 3 work work 4096 Jan 27 10:59 SimpleViewer drwxrwxr-x 3 work work 4096 Jan 20 22:10 SimpleViewer.java
我們就以SimpleRead為例,來測試一下。進入目錄,結構如下:
總用量 52 drwxrwxr-x 2 work work 4096 Jan 12 15:52 . drwxrwxr-x 12 work work 4096 Jan 12 15:52 .. -rw-rw-r-- 1 work work 5080 Mar 10 2020 CommonCppMakefile -rw-rw-r-- 1 work work 1710 Mar 10 2020 CommonDefs.mak -rw-rw-r-- 1 work work 538 Mar 10 2020 CommonTargets.mak -rw-rw-r-- 1 work work 631 Mar 10 2020 Makefile -rw-rw-r-- 1 work work 3535 Mar 10 2020 OniSampleUtilities.h -rw-rw-r-- 1 work work 493 Mar 10 2020 Platform.Arm -rw-rw-r-- 1 work work 521 Mar 10 2020 Platform.Arm64 -rw-rw-r-- 1 work work 150 Mar 10 2020 Platform.x64 -rw-rw-r-- 1 work work 531 Mar 10 2020 Platform.x86 -rw-rw-r-- 1 work work 3500 Mar 10 2020 main.cpp
include CommonDefs.mak BIN_DIR = Bin INC_DIRS = \ ../../Include \ ../Common SRC_FILES = *.cpp USED_LIBS += OpenNI2 EXE_NAME = SimpleRead CFLAGS += -Wall ifndef OPENNI2_INCLUDE $(error OPENNI2_INCLUDE is not defined. Please define it or 'source' the OpenNIDevEnvironment file from the installation) else ifndef OPENNI2_REDIST $(error OPENNI2_REDIST is not defined. Please define it or 'source' the OpenNIDevEnvironment file from the installation) endif INC_DIRS += $(OPENNI2_INCLUDE) include CommonCppMakefile .PHONY: copy-redist copy-redist: cp -R $(OPENNI2_REDIST)/* $(OUT_DIR) $(OUTPUT_FILE): copy-redist
把 INC_DIRS 中的 ../../Include \ 改成實際的 ../../include \,而 ../Common 目錄其實并不存在,也可以注釋掉。
main.cpp 文件
/***************************************************************************** * * * OpenNI 2.x Alpha * * Copyright (C) 2012 PrimeSense Ltd. * * * * This file is part of OpenNI. * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * *****************************************************************************/ #include <stdio.h> #include <OpenNI.h> #include "OniSampleUtilities.h" #define SAMPLE_READ_WAIT_TIMEOUT 2000 //2000ms using namespace openni; int main(int argc, char* argv[]) { Status rc = OpenNI::initialize(); if (rc != STATUS_OK) { printf("Initialize failed\n%s\n", OpenNI::getExtendedError()); return 1; } Device device; if (argc < 2) rc = device.open(ANY_DEVICE); else rc = device.open(argv[1]); if (rc != STATUS_OK) { printf("Couldn't open device\n%s\n", OpenNI::getExtendedError()); return 2; } VideoStream depth; if (device.getSensorInfo(SENSOR_DEPTH) != NULL) { rc = depth.create(device, SENSOR_DEPTH); if (rc != STATUS_OK) { printf("Couldn't create depth stream\n%s\n", OpenNI::getExtendedError()); return 3; } } rc = depth.start(); if (rc != STATUS_OK) { printf("Couldn't start the depth stream\n%s\n", OpenNI::getExtendedError()); return 4; } VideoFrameRef frame; while (!wasKeyboardHit()) { int changedStreamDummy; VideoStream* pStream = &depth; rc = OpenNI::waitForAnyStream(&pStream, 1, &changedStreamDummy, SAMPLE_READ_WAIT_TIMEOUT); if (rc != STATUS_OK) { printf("Wait failed! (timeout is %d ms)\n%s\n", SAMPLE_READ_WAIT_TIMEOUT, OpenNI::getExtendedError()); continue; } rc = depth.readFrame(&frame); if (rc != STATUS_OK) { printf("Read failed!\n%s\n", OpenNI::getExtendedError()); continue; } if (frame.getVideoMode().getPixelFormat() != PIXEL_FORMAT_DEPTH_1_MM && frame.getVideoMode().getPixelFormat() != PIXEL_FORMAT_DEPTH_100_UM) { printf("Unexpected frame format\n"); continue; } DepthPixel* pDepth = (DepthPixel*)frame.getData(); int middleIndex = (frame.getHeight()+1)*frame.getWidth()/2; printf("[%08llu] %8d\n", (long long)frame.getTimestamp(), pDepth[middleIndex]); } depth.stop(); depth.destroy(); device.close(); OpenNI::shutdown(); return 0; }
其實是將鏡頭中心的點所獲取到的深度信息不斷地進行輸出。
make
輸出
mkdir -p Bin/Intermediate/Arm64-Release/SimpleRead g++ -MD -MP -MT "./Bin/Intermediate/Arm64-Release/SimpleRead/main.d Bin/Intermediate/Arm64-Release/SimpleRead/main.o" -c -march=armv8-a -O3 -fno-tree-pre -fno-strict-aliasing -ftree-vectorize -ffast-math -funsafe-math-optimizations -flax-vector-conversions -Wall -O2 -DNDEBUG -I../../include -I/home/work/abc/OpenNI-Linux-Arm64-2.3.0.66/include -DXN_NEON -fPIC -fvisibility=hidden -Werror -o Bin/Intermediate/Arm64-Release/SimpleRead/main.o main.cpp mkdir -p Bin/Arm64-Release cp -R /home/work/abc/OpenNI-Linux-Arm64-2.3.0.66/Redist/* Bin/Arm64-Release g++ -o Bin/Arm64-Release/SimpleRead ./Bin/Intermediate/Arm64-Release/SimpleRead/main.o -LBin/Arm64-Release -lOpenNI2 -Wl,-rpath ./
會發現目錄下多了一個 Bin 目錄
├── Bin │ ├── Arm64-Release │ │ ├── OpenNI.ini │ │ ├── OpenNI2 │ │ ├── SimpleRead │ │ ├── libDepthUtils.a │ │ ├── libOpenNI2.so │ │ └── libSonixCamera.a │ └── Intermediate │ └── Arm64-Release ├── CommonCppMakefile ├── CommonDefs.mak ├── CommonTargets.mak ├── Makefile ├── OniSampleUtilities.h ├── Platform.Arm ├── Platform.Arm64 ├── Platform.x64 ├── Platform.x86 └── main.cpp
0 SimpleRead > ./Bin/Arm64-Release/SimpleRead Warning: USB events thread - failed to set priority. This might cause loss of data... [00000000] 3501 [00033688] 3501 [00067376] 3537 [00101065] 3501 [00303195] 3501 [00336884] 3537 [00370572] 3501 [00404261] 3501 . . .
可以看到,這里就輸出了深度信息。
至此,我們就把OpenNI在Linux/Ubuntu16.04-Arm64上安裝成功了。
看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注億速云行業資訊頻道,感謝您對億速云的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。