Jetson Cscore Error

Hi, so lately i have been trying to set up a jetson tx1 for our team’s vision processing to work better but there is an error that have had appeared while i was installing the Cscore. The actual story is i had no issue with jetson until last week but suddenly it stopped getting image data from webcams despite it sees it as a camera device only black images was what i was seeing. I tried everything i could but at the end i had to reinstall the jetpack. Before installing the jetpack there was an update for it so it is actually a different version then the last one which worked with cscore pretty fine. After os installation while package installing it showed no errors but when i opened jetson after setup i had to install cv manually and while installing cscore it could not install it. So is there anybody that has an idea of properly installing cscore to jetson tx1?

You are building cscore from source using cmake, correct? The likely issue is the newer OS image has OpenCV 4. Cscore was updated over the summer to support OpenCV 4, so you probably need to update your source tree. If you still have issues, I’ll need more information such as the error message you’re getting from the cscore build.

no, we are installing it by pip but how do i actually update my source tree. If i reflash it with no opencv packages and install an older opencv by myself would it work?

I don’t believe the Python version has been updated, so it won’t support OpenCV 4. You probably need to uninstall OpenCV and get a version in the 3 series.

the problem is when i check cv.version it says 3.2.0 but there is opencv4 in directories but i cannot find the apt name for it to remove because it is installed by jetson sdk package installer

Using a Jetson nano (not the TX) I ran into troubles that may be related to the opencv4 item mentioned. I tried to solve it and here’s where I wound up. Am I doing this the wrong way? Should I be trying to ‘downgrade’ opencv to opencv2 (or 3?) given cscore includes opencv2/* files? And if so, how is that done?

I looked around for an opencv2/ directory and found it under /usr/include/opencv4/opencv2/ and so I modified CMakeFile.txt to include /usr/include/opencv4 and that allowed compiles to move forward a bit - and then I ran into CvMat methods missing like cvarrToMat() in several places. This seems to me like a library that has moved forward with code that hasn’t.

Thoughts?

bob

Are you building with the allwpilib repo? The separate cscore repo is no longer maintained. The allwpilib repo has fixes for opencv4.

I have tried both. The complaints above are more targeted at my attempt to compile an older set of code from last year to at least give me some confidence. But those weren’t the allwpilib/ version.

I did, however, try doing allwpilib and I was unable to get a clean ‘cmake’ to happen. Sigh. I re-read the README-CMAKE tonight and hope to give another try using a folder ‘buildcmake/’ and then ‘cmake …’ from in there, but I’m a little pessimistic that this simple item is what tripped me up.

Have you (or others) been successful in compiling allwpilib for nano?

Thanks
bob - Team 1967 - The Janksters

Usually, the biggest issue people run into is by default Java builds are enabled, which require OpenCV to be built with Java support. Not all distros provide this in their opencv builds. If you don’t need Java support, you can disable it in the cmake build easily with -DWITHOUT_JAVA=ON. Otherwise, you will need to build OpenCV with Java support enabled.

Another option if you just want builds is we actually provide aarch64 builds of all wpilib libraries prebuilt specifically designed for and tested on the Jetson Nano. They can be found in the maven repo at

https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/

Or you can easily add aarch64 support to a GradleRIO build and get a binary built with our cross compiler. If this is the path you want, I can help with what needs to be added. Its not well documented, but it definitely does work.

Thad - thanks for the reply!
a) I’d like to be able to build it myself, but I’m not ‘stuck’ on the idea. Ha! I did have the WITHOUT_JAVA on my list of things to try. My plan was to …
cd allwpilib
mkdir buildcmake
cd buildcmake
cmake -DWITHOUT_JAVA=ON …
make

Does that seem right? This whole thing about not building from within the allwpilib folder hierarchy got me puzzled until I saw the mention of gitignore and buildcmake/ … details here would be great.

Your link sounded very promising, but I went to it and dug through looking at ntcore and cscore which are the two libraries I need on nano and I didn’t see any reference to the Jetson nano for the builds. Which should I choose or are they elsewhere?

Thanks!
bob

Yes, out-of-tree is the right way to build with cmake.

The usual first issue with cmake builds with Java enabled is not having JAVA_HOME set. You need openjdk-11-jdk installed and JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64. The usual second issue is that the opencv jar isn’t available; this is harder to fix.

If you don’t care about Java, -DWITHOUT_JAVA=ON is correct.

I just successfully built both ways on a Nano.

The Jetson builds are the ones suffixed with linuxaarch64bionic. In theory they work on any aarch system running Ubuntu bionic, so they’re not Jetson specific, but that is the Jetson platform and is, and what they’re tested with.

Super, guys - thanks for both sets of advice and pointers. I’ll give these a shot this weekend or possibly even sooner and report back!

Thanks,
bob

Hey Peter,
In the absence of being able to work with the nano until the weekend, I wanted to give a shot at compiling allwpilib on my mac just to see that I can get past any cmake issues etc. What I ran into is quite similar or identical to one of the trials I did on the nano this past weekend so I’d like to see if you might be able to help me through this item on the mac as it’ll likely solve it for nano too.

On Mac:
cd allwpilib ; mkdir buildcmake ; cd buildcmake
cmake -DWITHOUT_JAVA=ON …

The response looks healthy until this error about OpenCV…

– The C compiler identification is AppleClang 10.0.1.10010046
– The CXX compiler identification is AppleClang 10.0.1.10010046
– 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
– Looking for pthread.h
– Looking for pthread.h - found
– Looking for pthread_create
– Looking for pthread_create - found
– Found Threads: TRUE
CMake Error at cscore/CMakeLists.txt:7 (find_package):
By not providing “FindOpenCV.cmake” in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by “OpenCV”, but
CMake did not find one.

Could not find a package configuration file provided by “OpenCV” with any
of the following names:

OpenCVConfig.cmake
opencv-config.cmake

Add the installation prefix of “OpenCV” to CMAKE_PREFIX_PATH or set
“OpenCV_DIR” to a directory containing one of the above files. If “OpenCV”
provides a separate development package or SDK, be sure it has been
installed.

– Configuring incomplete, errors occurred!
See also “/Users/rwolff/dev/robotics/allwpilib/buildcmake/CMakeFiles/CMakeOutput.log”.
See also “/Users/rwolff/dev/robotics/allwpilib/buildcmake/CMakeFiles/CMakeError.log”.

You do need OpenCV development libraries and headers installed to build cscore with cmake. As long as you have libopencv-dev installed on the Nano, it should be able to find OpenCV. Note you can use ccmake (installed by cmake-curses-gui on Ubuntu) to help configure some of these settings interactively.

I know this was for testing purposes, but if you really do want to build for Mac, we provide Maven packages for OpenCV for that platform, so you can build with Gradle instead of cmake.

Got it - thanks again Peter. I’ll keep that in mind this weekend for the nano. I believe it has a dev version of opencv given that there are headers in /usr/include/opencv4/ but I can’t be certain it’s an appropriate version of opencv that allwpilib will like. Is there anything I should “vet” there to ensure success?

bob

Thad, I’m not quite sure how to use the binaries (e.g. where to install them and which ones I need). Is there any guidance? I’m trying to install the allwpilib using cmake and make, but it is not intuitive after the install completes (successfully) what paths I should be using for my includes… ??

Really at this point all I need is ntcore for a vision application with Network Tables on the Jetson. I’m not sure if I need anything else at this point…

Any help would be appreciated. I’m trying to keep it simple to have a simple build process.

If you didn’t set CMAKE_INSTALL_PREFIX, it defaults to /usr/local. So include files will be in /usr/local/include, libraries in /usr/local/lib. If you just want NetworkTables you’ll want to compile with -I/usr/local/include and link with -L/usr/local/lib -lntcore.

Interestingly, nothing at all shows up in /usr/local/include or /usr/local/lib. Maybe I’m doing something wrong… Here is basically what I did:

git clone https://github.com/wpilibsuite/allwpilib
cd allwpilib
mkdir buildcmake
cd buildcmake
cmake -DWITHOUT_JAVA=ON …
make

Did you do (sudo) make install?