Giter VIP home page Giter VIP logo

buildopencvtx2's Introduction

buildOpenCVTX2

Build and install OpenCV for the NVIDIA Jetson TX2

These scripts build OpenCV version 3.4 for the NVIDIA Jetson TX2 Development Kit. Please see Releases/Tags for earlier versions.

OpenCV is a rich environment which can be configured in many different ways. You should configure OpenCV for your needs, by modifying the build file "buildOpenCV.sh". Note that selecting different options in OpenCV may also have additional library requirements which are not included in these scripts. Please read the notes below for other important points before installing.

The buildOpenCV script has two optional command line parameters:

  • -s | --sourcedir Directory in which to place the opencv sources (default $HOME)
  • -i | --installdir Directory in which to install opencv libraries (default /usr/local)

To run the the build file:

$ ./buildOpenCV.sh -s <file directory>

This example will build OpenCV in the given file directory and install OpenCV in the /usr/local directory.

The folder ~/opencv and (optional) ~/opencv_extras contain the source, build and extra data files. If you wish to remove them after installation, a convenience script is provided:

$ ./removeOpenCVSources.sh -d <file directory>

where the <file directory> contains the OpenCV source.

The folder ~/opencv and ~/opencv_extras contain the source, build and extra data files. If you wish to remove them after installation, a convenience script is provided:

$ ./removeOpenCVSources.sh

Packaging

An alternative build script, buildAndPackageOpenCV.sh , will build the OpenCV package as described above and the build .deb files using the standard OpenCV mechanism defined using the CPACK_BINARY_DEB=ON in the OpenCV Make file. See the script.

The buildAndPackageOpenCV script has two optional command line parameters:

  • -s | --sourcedir Directory in which to place the opencv sources (default $HOME)
  • -i | --installdir Directory in which to install opencv libraries (default /usr/local)

To run the the build file:

$ ./buildAndPackageOpenCV.sh -s <file directory>

This example will build OpenCV in the given file directory and install OpenCV in the /usr/local directory.

The corresponding .deb files will be in the <file directory>/opencv/build directory in .deb file and compressed forms.

Installing .deb files

To install .deb files:

Switch to the directory where the .deb files are located. Then:

$ sudo dpkg -i OpenCV-<OpenCV Version info>-aarch64-libs.deb

For example: $ sudo dpkg -i OpenCV-3.4.1-1-g75a2577-aarch64-libs.deb

$ sudo apt-get install -f

$ sudo dpkg -i OpenCV-<OpenCV Version info>-aarch64-dev.deb

$ sudo dpkg -i OpenCV-<OpenCV Version info>-aarch64-python.deb

The libraries will be installed in /usr/lib

Binaries are in /usr/bin

opencv.pc is in /usr/lib/pkgconfig

Package Notes:

  • The build process default installation is in /usr/local Note that the .deb file install into /usr
  • After installation, the dpkg/apt name does not include version information, e.g. the name is opencv-libs

Notes

There may be issues if different version of OpenCV are installed. JetPack normally installs OpenCV in the /usr folder. You will need to consider if this is appropriate for your application. It is important to realize that many packages may rely on OpenCV. The standard installation by JetPack places the OpenCV libraries in the /usr directory.

You may consider removing OpenCV installed by JetPack before performing this script installation:

$ sudo apt-get purge libopencv*

With this script release, the script now installs OpenCV in /usr/local. Earlier versions of this script installed in /usr. You may have to set your include and libraries and/or PYTHONPATH to point to the new version. See the Examples folder. Alternatively, you may want to change the script to install into the /usr directory.

The Jetson is an aarch64 machine, which means that the OpenCV configuration variable ENABLE_NEON is ignored. The compiler includes NEON support for all machines with aarch64 architecture.

These scripts rely on OpenCV finding the correct CUDA version, instead of setting it manually.

Special thanks to Daniel (Github user @dkoguciuk) for script cleanup.

References

Most of this information is derived from:

http://docs.opencv.org/3.2.0/d6/d15/tutorial_building_tegra_cuda.html

https://devtalk.nvidia.com/default/topic/965134/opencv-3-1-compilation-on-tx1-lets-collect-the-quot-definitive-quot-cmake-settings-/?offset=3

Release Notes

June 2018

  • L4T 28.2
  • CUDA 9
  • OpenCV 3.4
  • Added command line arguments to set source and installation directories
  • Add a script to build OpenCV .deb packages.
  • Add upstream patch for C library compilation issues

May 2018

  • L4T 28.2
  • CUDA 9
  • OpenCV 3.4
  • OpenGL support added to build script
  • Fast Math support (cuBLAS) added
  • Supports both Python 2 and Python 3
  • Canny Detection example supports built-in camera and USB camera. See the Examples folder

September 2017

  • L4T 28.1
  • CUDA 8
  • OpenCV 3.3
  • GStreamer support added to build script
  • GStreamer OpenCV examples using the Jetson onboard camera

April 2017

  • Initial Release
  • L4T 27.1
  • OpenCV 3.2

License

MIT License

Copyright (c) 2017-2018 Jetsonhacks

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

buildopencvtx2's People

Contributors

dkoguciuk avatar jetsonhacks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

buildopencvtx2's Issues

Build Error

Hi all,
I install OpenCV package as the following step:

./buildOpenCV.sh
make
sudo make install

However,I got these error

Scanning dependencies of target opencvtest
[ 50%] Building CXX object CMakeFiles/opencvtest.dir/main.cpp.o
[100%] Linking CXX executable opencvtest
CMakeFiles/opencvtest.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x28): undefined reference to `cv::VideoCapture::VideoCapture(int)'
main.cpp:(.text+0x30): undefined reference to `cv::VideoCapture::isOpened() const'
main.cpp:(.text+0x58): undefined reference to `cv::VideoCapture::get(int) const'
main.cpp:(.text+0x68): undefined reference to `cv::VideoCapture::get(int) const'
main.cpp:(.text+0x98): undefined reference to `cv::namedWindow(cv::String const&, int)'
main.cpp:(.text+0xac): undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
main.cpp:(.text+0xb0): undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
main.cpp:(.text+0xf8): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
main.cpp:(.text+0x110): undefined reference to `cv::waitKey(int)'
main.cpp:(.text+0x12c): undefined reference to `cv::VideoCapture::~VideoCapture()'
main.cpp:(.text+0x194): undefined reference to `cv::VideoCapture::~VideoCapture()'
CMakeFiles/opencvtest.dir/main.cpp.o: In function `cv::String::String(char const*)':
main.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x4c): undefined reference to `cv::String::allocate(unsigned long)'
CMakeFiles/opencvtest.dir/main.cpp.o: In function `cv::String::~String()':
main.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x10): undefined reference to `cv::String::deallocate()'
CMakeFiles/opencvtest.dir/main.cpp.o: In function `cv::String::operator=(cv::String const&)':
main.cpp:(.text._ZN2cv6StringaSERKS0_[_ZN2cv6StringaSERKS0_]+0x2c): undefined reference to `cv::String::deallocate()'
CMakeFiles/opencvtest.dir/main.cpp.o: In function `cv::Mat::~Mat()':
main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x34): undefined reference to `cv::fastFree(void*)'
CMakeFiles/opencvtest.dir/main.cpp.o: In function `cv::Mat::release()':
main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x58): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
CMakeFiles/opencvtest.dir/build.make:94: recipe for target 'opencvtest' failed
make[2]: *** [opencvtest] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/opencvtest.dir/all' failed
make[1]: *** [CMakeFiles/opencvtest.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I have checked the packge is installed in the directory /usr/local/lib
Can anyone help me?
Thanks in advance!!

opencv build error

Hi, previously I had problem realizing realtime SSD detection with V4L2 format error which seems to be an opencv error. So I decided to reinstall opencv following the instruction. However, I got the following error at 75% completion:

[ 75%] Building CXX object modules/python2/CMakeFiles/opencv_python2.dir//src2/cv2.cpp.o
In file included from /home/nvidia/opencv/modules/python/src2/cv2.cpp:1681:0:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:2996:46: error: ‘Importer’ is not a member of ‘cv::dnn’
template<> PyObject* pyopencv_from(const Ptrcv::dnn::Importer& r)
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:2996:46: error: ‘Importer’ is not a member of ‘cv::dnn’
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:2996:63: error: template argument 1 is invalid
template<> PyObject* pyopencv_from(const Ptrcv::dnn::Importer& r)
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:2996:22: error: redefinition of ‘PyObject* pyopencv_from(const T&) [with T = int; PyObject = _object]’
template<> PyObject* pyopencv_from(const Ptrcv::dnn::Importer& r)
^
/home/nvidia/opencv/modules/python/src2/cv2.cpp:796:11: note: ‘PyObject* pyopencv_from(const T&) [with T = int; PyObject = _object]’ previously declared here
PyObject* pyopencv_from(const int& value)
^
In file included from /home/nvidia/opencv/modules/python/src2/cv2.cpp:1681:0:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:3004:48: error: ‘Importer’ is not a member of ‘cv::dnn’
template<> bool pyopencv_to(PyObject* src, Ptrcv::dnn::Importer& dst, const char* name)
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:3004:48: error: ‘Importer’ is not a member of ‘cv::dnn’
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:3004:65: error: template argument 1 is invalid
template<> bool pyopencv_to(PyObject* src, Ptrcv::dnn::Importer& dst, const char* name)
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:3004:17: error: redefinition of ‘bool pyopencv_to(PyObject*, T&, const char*) [with T = int; PyObject = _object]’
template<> bool pyopencv_to(PyObject* src, Ptrcv::dnn::Importer& dst, const char* name)
^
/home/nvidia/opencv/modules/python/src2/cv2.cpp:802:6: note: ‘bool pyopencv_to(PyObject*, T&, const char*) [with T = int; PyObject = _object]’ previously declared here
bool pyopencv_to(PyObject* obj, int& value, const char* name)
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h: In function ‘PyObject* pyopencv_cv_dnn_dnn_Net_getLayerShapes(PyObject*, PyObject*, PyObject*)’:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:15291:96: error: no matching function for call to ‘cv::dnn::experimental_dnn_v4::Net::getLayerShapes(cv::dnn::experimental_dnn_v4::MatShape&, int&, vector_MatShape*, vector_MatShape*)’
ERRWRAP2(self->getLayerShapes(netInputShape, layerId, &inLayerShapes, &outLayerShapes));
^
/home/nvidia/opencv/modules/python/src2/cv2.cpp:87:5: note: in definition of macro ‘ERRWRAP2’
expr;
^
In file included from /home/nvidia/opencv/build/modules/python2/pyopencv_generated_include.h:17:0,
from /home/nvidia/opencv/modules/python/src2/cv2.cpp:22:
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:521:14: note: candidate: void cv::dnn::experimental_dnn_v4::Net::getLayerShapes(const MatShape&, int, std::vector<std::vector >&, std::vector<std::vector >&) const
void getLayerShapes(const MatShape& netInputShape,
^
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:521:14: note: no known conversion for argument 3 from ‘vector_MatShape* {aka std::vector<std::vector >}’ to ‘std::vector<std::vector >&’
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:527:14: note: candidate: void cv::dnn::experimental_dnn_v4::Net::getLayerShapes(const std::vector<std::vector >&, int, std::vector<std::vector >&, std::vector<std::vector >&) const
void getLayerShapes(const std::vector& netInputShapes,
^
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:527:14: note: no known conversion for argument 1 from ‘cv::dnn::experimental_dnn_v4::MatShape {aka std::vector}’ to ‘const std::vector<std::vector >&’
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:15312:97: error: no matching function for call to ‘cv::dnn::experimental_dnn_v4::Net::getLayerShapes(vector_MatShape&, int&, vector_MatShape
, vector_MatShape*)’
ERRWRAP2(self->getLayerShapes(netInputShapes, layerId, &inLayerShapes, &outLayerShapes));
^
/home/nvidia/opencv/modules/python/src2/cv2.cpp:87:5: note: in definition of macro ‘ERRWRAP2’
expr;
^
In file included from /home/nvidia/opencv/build/modules/python2/pyopencv_generated_include.h:17:0,
from /home/nvidia/opencv/modules/python/src2/cv2.cpp:22:
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:521:14: note: candidate: void cv::dnn::experimental_dnn_v4::Net::getLayerShapes(const MatShape&, int, std::vector<std::vector >&, std::vector<std::vector >&) const
void getLayerShapes(const MatShape& netInputShape,
^
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:521:14: note: no known conversion for argument 1 from ‘vector_MatShape {aka std::vector<std::vector >}’ to ‘const MatShape& {aka const std::vector&}’
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:527:14: note: candidate: void cv::dnn::experimental_dnn_v4::Net::getLayerShapes(const std::vector<std::vector >&, int, std::vector<std::vector >&, std::vector<std::vector >&) const
void getLayerShapes(const std::vector& netInputShapes,
^
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:527:14: note: no known conversion for argument 3 from ‘vector_MatShape* {aka std::vector<std::vector >}’ to ‘std::vector<std::vector >&’
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h: In function ‘PyObject
pyopencv_cv_dnn_dnn_Net_getLayersShapes(PyObject*, PyObject*, PyObject*)’:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:15390:103: error: no matching function for call to ‘cv::dnn::experimental_dnn_v4::Net::getLayersShapes(vector_MatShape&, vector_int*, vector_vector_MatShape*, vector_vector_MatShape*)’
ERRWRAP2(self->getLayersShapes(netInputShapes, &layersIds, &inLayersShapes, &outLayersShapes));
^
/home/nvidia/opencv/modules/python/src2/cv2.cpp:87:5: note: in definition of macro ‘ERRWRAP2’
expr;
^
In file included from /home/nvidia/opencv/build/modules/python2/pyopencv_generated_include.h:17:0,
from /home/nvidia/opencv/modules/python/src2/cv2.cpp:22:
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:501:22: note: candidate: void cv::dnn::experimental_dnn_v4::Net::getLayersShapes(const std::vector<std::vector >&, std::vector&, std::vector<std::vector<std::vector > >&, std::vector<std::vector<std::vector > >&) const
CV_WRAP void getLayersShapes(const std::vector& netInputShapes,
^
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:501:22: note: no known conversion for argument 2 from ‘vector_int* {aka std::vector}’ to ‘std::vector&’
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:507:22: note: candidate: void cv::dnn::experimental_dnn_v4::Net::getLayersShapes(const MatShape&, std::vector&, std::vector<std::vector<std::vector > >&, std::vector<std::vector<std::vector > >&) const
CV_WRAP void getLayersShapes(const MatShape& netInputShape,
^
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:507:22: note: no known conversion for argument 1 from ‘vector_MatShape {aka std::vector<std::vector >}’ to ‘const MatShape& {aka const std::vector&}’
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:15413:102: error: no matching function for call to ‘cv::dnn::experimental_dnn_v4::Net::getLayersShapes(cv::dnn::experimental_dnn_v4::MatShape&, vector_int
, vector_vector_MatShape*, vector_vector_MatShape*)’
ERRWRAP2(self->getLayersShapes(netInputShape, &layersIds, &inLayersShapes, &outLayersShapes));
^
/home/nvidia/opencv/modules/python/src2/cv2.cpp:87:5: note: in definition of macro ‘ERRWRAP2’
expr;
^
In file included from /home/nvidia/opencv/build/modules/python2/pyopencv_generated_include.h:17:0,
from /home/nvidia/opencv/modules/python/src2/cv2.cpp:22:
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:501:22: note: candidate: void cv::dnn::experimental_dnn_v4::Net::getLayersShapes(const std::vector<std::vector >&, std::vector&, std::vector<std::vector<std::vector > >&, std::vector<std::vector<std::vector > >&) const
CV_WRAP void getLayersShapes(const std::vector& netInputShapes,
^
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:501:22: note: no known conversion for argument 1 from ‘cv::dnn::experimental_dnn_v4::MatShape {aka std::vector}’ to ‘const std::vector<std::vector >&’
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:507:22: note: candidate: void cv::dnn::experimental_dnn_v4::Net::getLayersShapes(const MatShape&, std::vector&, std::vector<std::vector<std::vector > >&, std::vector<std::vector<std::vector > >&) const
CV_WRAP void getLayersShapes(const MatShape& netInputShape,
^
/home/nvidia/opencv/modules/dnn/include/opencv2/dnn/dnn.hpp:507:22: note: no known conversion for argument 2 from ‘vector_int* {aka std::vector}’ to ‘std::vector&’
In file included from /home/nvidia/opencv/modules/python/src2/cv2.cpp:1681:0:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h: In function ‘PyObject
pyopencv_cv_dnn_dnn_Importer_populateNet(PyObject*, PyObject*, PyObject*)’:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:15747:5: error: ‘Importer’ is not a member of ‘cv::dnn’
cv::dnn::Importer* self = NULL;
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:15747:24: error: ‘self’ was not declared in this scope
cv::dnn::Importer* self = NULL;
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:15749:40: error: ‘Importer’ in namespace ‘cv::dnn’ does not name a type
self = dynamic_castcv::dnn::Importer*(((pyopencv_dnn_Importer_t*)self)->v.get());
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:15749:48: error: expected ‘>’ before ‘’ token
self = dynamic_castcv::dnn::Importer*(((pyopencv_dnn_Importer_t
)self)->v.get());
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:15749:48: error: expected ‘(’ before ‘’ token
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:15749:49: error: expected primary-expression before ‘>’ token
self = dynamic_castcv::dnn::Importer*(((pyopencv_dnn_Importer_t
)self)->v.get());
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_types.h:15749:93: error: expected ‘)’ before ‘;’ token
self = dynamic_castcv::dnn::Importer*(((pyopencv_dnn_Importer_t*)self)->v.get());
^
In file included from /home/nvidia/opencv/modules/python/src2/cv2.cpp:1682:0:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h: In function ‘PyObject* pyopencv_cv_dnn_createCaffeImporter(PyObject*, PyObject*, PyObject*)’:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h:16785:9: error: ‘Importer’ was not declared in this scope
Ptr retval;
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h:16785:17: error: template argument 1 is invalid
Ptr retval;
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h:16792:27: error: ‘createCaffeImporter’ is not a member of ‘cv::dnn’
ERRWRAP2(retval = cv::dnn::createCaffeImporter(prototxt, caffeModel));
^
/home/nvidia/opencv/modules/python/src2/cv2.cpp:87:5: note: in definition of macro ‘ERRWRAP2’
expr;
^
In file included from /home/nvidia/opencv/modules/python/src2/cv2.cpp:1682:0:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h: In function ‘PyObject* pyopencv_cv_dnn_createTensorflowImporter(PyObject*, PyObject*, PyObject*)’:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h:16805:9: error: ‘Importer’ was not declared in this scope
Ptr retval;
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h:16805:17: error: template argument 1 is invalid
Ptr retval;
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h:16811:27: error: ‘createTensorflowImporter’ is not a member of ‘cv::dnn’
ERRWRAP2(retval = cv::dnn::createTensorflowImporter(model));
^
/home/nvidia/opencv/modules/python/src2/cv2.cpp:87:5: note: in definition of macro ‘ERRWRAP2’
expr;
^
In file included from /home/nvidia/opencv/modules/python/src2/cv2.cpp:1682:0:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h: In function ‘PyObject* pyopencv_cv_dnn_createTorchImporter(PyObject*, PyObject*, PyObject*)’:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h:16825:9: error: ‘Importer’ was not declared in this scope
Ptr retval;
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h:16825:17: error: template argument 1 is invalid
Ptr retval;
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_funcs.h:16831:27: error: ‘createTorchImporter’ is not a member of ‘cv::dnn’
ERRWRAP2(retval = cv::dnn::createTorchImporter(filename, isBinary));
^
/home/nvidia/opencv/modules/python/src2/cv2.cpp:87:5: note: in definition of macro ‘ERRWRAP2’
expr;
^
In file included from /home/nvidia/opencv/modules/python/src2/cv2.cpp:1743:0:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h: At global scope:
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1848:26: error: ‘MAX’ is not a member of ‘cv::dnn::experimental_dnn_v4::EltwiseLayer’
{"EltwiseLayer_MAX", cv::dnn::EltwiseLayer::MAX},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1849:27: error: ‘MAX’ is not a member of ‘cv::dnn::experimental_dnn_v4::EltwiseLayer’
{"ELTWISE_LAYER_MAX", cv::dnn::EltwiseLayer::MAX},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1850:27: error: ‘PROD’ is not a member of ‘cv::dnn::experimental_dnn_v4::EltwiseLayer’
{"EltwiseLayer_PROD", cv::dnn::EltwiseLayer::PROD},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1851:28: error: ‘PROD’ is not a member of ‘cv::dnn::experimental_dnn_v4::EltwiseLayer’
{"ELTWISE_LAYER_PROD", cv::dnn::EltwiseLayer::PROD},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1852:26: error: ‘SUM’ is not a member of ‘cv::dnn::experimental_dnn_v4::EltwiseLayer’
{"EltwiseLayer_SUM", cv::dnn::EltwiseLayer::SUM},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1853:27: error: ‘SUM’ is not a member of ‘cv::dnn::experimental_dnn_v4::EltwiseLayer’
{"ELTWISE_LAYER_SUM", cv::dnn::EltwiseLayer::SUM},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1854:30: error: ‘CHANNEL_NRM’ is not a member of ‘cv::dnn::experimental_dnn_v4::LRNLayer’
{"LRNLayer_CHANNEL_NRM", cv::dnn::LRNLayer::CHANNEL_NRM},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1855:30: error: ‘CHANNEL_NRM’ is not a member of ‘cv::dnn::experimental_dnn_v4::LRNLayer’
{"LRNLAYER_CHANNEL_NRM", cv::dnn::LRNLayer::CHANNEL_NRM},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1856:30: error: ‘SPATIAL_NRM’ is not a member of ‘cv::dnn::experimental_dnn_v4::LRNLayer’
{"LRNLayer_SPATIAL_NRM", cv::dnn::LRNLayer::SPATIAL_NRM},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1857:30: error: ‘SPATIAL_NRM’ is not a member of ‘cv::dnn::experimental_dnn_v4::LRNLayer’
{"LRNLAYER_SPATIAL_NRM", cv::dnn::LRNLayer::SPATIAL_NRM},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1858:26: error: ‘AVE’ is not a member of ‘cv::dnn::experimental_dnn_v4::PoolingLayer’
{"PoolingLayer_AVE", cv::dnn::PoolingLayer::AVE},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1859:27: error: ‘AVE’ is not a member of ‘cv::dnn::experimental_dnn_v4::PoolingLayer’
{"POOLING_LAYER_AVE", cv::dnn::PoolingLayer::AVE},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1860:26: error: ‘MAX’ is not a member of ‘cv::dnn::experimental_dnn_v4::PoolingLayer’
{"PoolingLayer_MAX", cv::dnn::PoolingLayer::MAX},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1861:27: error: ‘MAX’ is not a member of ‘cv::dnn::experimental_dnn_v4::PoolingLayer’
{"POOLING_LAYER_MAX", cv::dnn::PoolingLayer::MAX},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1862:33: error: ‘STOCHASTIC’ is not a member of ‘cv::dnn::experimental_dnn_v4::PoolingLayer’
{"PoolingLayer_STOCHASTIC", cv::dnn::PoolingLayer::STOCHASTIC},
^
/home/nvidia/opencv/build/modules/python2/pyopencv_generated_ns_reg.h:1863:34: error: ‘STOCHASTIC’ is not a member of ‘cv::dnn::experimental_dnn_v4::PoolingLayer’
{"POOLING_LAYER_STOCHASTIC", cv::dnn::PoolingLayer::STOCHASTIC},
^
/home/nvidia/opencv/build/modules/python_bindings_generator/pyopencv_generated_type_publish.h: In function ‘void initcv2()’:
/home/nvidia/opencv/build/modules/python_bindings_generator/pyopencv_generated_type_publish.h:24:37: error: ‘pyopencv_ml_ANN_MLP_ANNEAL_Type’ was not declared in this scope
PUBLISH_OBJECT("ml_ANN_MLP_ANNEAL", pyopencv_ml_ANN_MLP_ANNEAL_Type);
^
/home/nvidia/opencv/modules/python/src2/cv2.cpp:1806:75: note: in definition of macro ‘PUBLISH_OBJECT’
#define PUBLISH_OBJECT(name, type) _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA (&type)->ob_refcnt++;
^
/home/nvidia/opencv/build/modules/python_bindings_generator/pyopencv_generated_type_publish.h:85:48: error: ‘pyopencv_CirclesGridFinderParameters2_Type’ was not declared in this scope
PUBLISH_OBJECT("CirclesGridFinderParameters2", pyopencv_CirclesGridFinderParameters2_Type);
^
/home/nvidia/opencv/modules/python/src2/cv2.cpp:1806:75: note: in definition of macro ‘PUBLISH_OBJECT’
#define PUBLISH_OBJECT(name, type) _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA (&type)->ob_refcnt++;
^
modules/python2/CMakeFiles/opencv_python2.dir/build.make:62: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/
/src2/cv2.cpp.o' failed
make[2]: *** [modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o] Error 1
CMakeFiles/Makefile2:6244: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/all' failed
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
Make did not successfully build
Please fix issues and retry build


Previously I installed opencv3.4.0 myself following other tutorial. And it seems in my home directory, there were opencvtegra folders installed before (there was another collegue working on this Jetson TX2 before). I unistalled opencv by "sudo apt-get purge libopencv*" and removed opencvtegra foler. Any idea what might be the problem?

Thanks in advance!

Installing OpenCV 3.3.0 with opencv-contrib, but got error during make

Hi,
I installing opencv 3.3.0 on my raspberry pi 3, using the cmake with the following configure:
cmake -D CMAKE_BUILD_TYPE=RELEASE
-D INSTALL_C_EXAMPLES=OFF
-D INSTALL_PYTHON_EXAMPLES=ON
-D CMAKE_INSTALL_PREFIX=/usr/local
-D WITH_V4L=ON
-D INSTALL_CREATE_DISTRIB=ON
-D ENABLE_NEON=ON
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules
-D BUILD_EXAMPLES=ON ..

But ended up, with the following error

CMakeFiles/opencv_perf_imgproc.dir/__/imgproc/perf/opencl/perf_pyramid.cpp.o: file not recognized: File truncated
collect2: error: ld returned 1 exit status
modules/world/CMakeFiles/opencv_perf_imgproc.dir/build.make:1033: recipe for target 'bin/opencv_perf_imgproc' failed
make[2]: *** [bin/opencv_perf_imgproc] Error 1
CMakeFiles/Makefile2:5038: recipe for target 'modules/world/CMakeFiles/opencv_perf_imgproc.dir/all' failed
make[1]: *** [modules/world/CMakeFiles/opencv_perf_imgproc.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

#error Please include the appropriate gl headers before including cuda_gl_interop.h

[ 37%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o
cc1plus: warning: /home/nvidia/opencv/build/modules/core/precomp.hpp.gch/opencv_core_RELEASE.gch: not used because `OPENCV_TRAITS_ENABLE_DEPRECATED' is defined [-Winvalid-pch]
cc1plus: warning: /home/nvidia/opencv/build/modules/core/precomp.hpp.gch/opencv_core_RELEASE.gch: not used because `OPENCV_TRAITS_ENABLE_DEPRECATED' is defined [-Winvalid-pch]
cc1plus: warning: /home/nvidia/opencv/build/modules/core/precomp.hpp.gch/opencv_core_RELEASE.gch: not used because `OPENCV_TRAITS_ENABLE_DEPRECATED' is defined [-Winvalid-pch]
In file included from /home/nvidia/opencv/modules/core/src/opengl.cpp:48:0:
/usr/local/cuda-9.0/include/cuda_gl_interop.h:64:2: error: #error Please include the appropriate gl headers before including cuda_gl_interop.h
 #error Please include the appropriate gl headers before including cuda_gl_interop.h
  ^
modules/core/CMakeFiles/opencv_core.dir/build.make:1289: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o' failed
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:1803: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

real	0m12.178s
user	0m20.228s
sys	0m3.204s
Make did not build 
Retrying ... 
[  0%] Built target gen-pkgconfig
[  7%] Built target libwebp
[ 11%] Built target IlmImf
[ 15%] Built target libprotobuf
[ 18%] Built target carotene_objs
[ 19%] Built target tegra_hal
[ 19%] Built target opencv_cudev
[ 19%] Built target opencv_ts_pch_dephelp
[ 19%] Built target pch_Generate_opencv_ts
[ 19%] Built target opencv_core_pch_dephelp
[ 20%] Built target pch_Generate_opencv_core
[ 20%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o
cc1plus: warning: /home/nvidia/opencv/build/modules/core/precomp.hpp.gch/opencv_core_RELEASE.gch: not used because `OPENCV_TRAITS_ENABLE_DEPRECATED' is defined [-Winvalid-pch]
In file included from /home/nvidia/opencv/modules/core/src/opengl.cpp:48:0:
/usr/local/cuda-9.0/include/cuda_gl_interop.h:64:2: error: #error Please include the appropriate gl headers before including cuda_gl_interop.h
 #error Please include the appropriate gl headers before including cuda_gl_interop.h
  ^
modules/core/CMakeFiles/opencv_core.dir/build.make:1289: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o' failed
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o] Error 1
CMakeFiles/Makefile2:1803: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
Make did not successfully build
Please fix issues and retry build

Hello,
Any idea ??
Thanks,
Vincent

Example Error - Python is missing OpenCV

Hello,

i did you installation tutorial as you said. But it seems like, my python doesnt know which OpenCV version to use.
When i try your Example, i get an error and the hint, that python is accessing openCV version 3.3.1
The error looks like this
Called with args: Namespace(video_device=0) OpenCV version: 3.3.1-dev ('Device Number:', 0) camera open failed
I think python doesnt know that i build openCV from source. I double checked in the terminal an i get these issues:

`nvidia@tegra-ubuntu:~/OpenCVTX2/Examples$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.

import cv
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'cv'
import cv2
Traceback (most recent call last):
File "", line 1, in
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type
`
What have i done wrong in the build process?

Opencv dnn doesnot use GPU

I m using the following to detect objects using SSD mobilenet (CAffe) on Jetson TX2 with opencv3.4.1 and Cuda 9.0

blob = cv2.dnn.blobFromImage(cv2.resize(frame, (300, 300)), 0.007843, (300, 300), 127.5)
net.setInput(blob)
detections = net.forward()

The tegrastats show no GPU usage at all. All the cores of the CPU are utilized properly, however GPU utilisation is zero.

How can I enable GPU usage on the Jetson for faster FPS on videos ?

Thanks

build error

Hi I getthe following error when I try ti run ./buildOpenCv
Looking for ccache - not found
-- Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found suitable version "1.2.11", minimum required is "1.2.3")
-- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR)
-- Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR)
-- Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR)
-- Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found version "1.2.11")
CMake Warning at cmake/OpenCVFindLibsGUI.cmake:18 (find_package):
By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5Core", but
CMake did not find one.

Could not find a package configuration file provided by "Qt5Core" with any
of the following names:

Qt5CoreConfig.cmake
qt5core-config.cmake

Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set
"Qt5Core_DIR" to a directory containing one of the above files. If
"Qt5Core" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
CMakeLists.txt:635 (include)

CMake Warning at cmake/OpenCVFindLibsGUI.cmake:19 (find_package):
By not providing "FindQt5Gui.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5Gui", but
CMake did not find one.

Could not find a package configuration file provided by "Qt5Gui" with any
of the following names:

Qt5GuiConfig.cmake
qt5gui-config.cmake

Add the installation prefix of "Qt5Gui" to CMAKE_PREFIX_PATH or set
"Qt5Gui_DIR" to a directory containing one of the above files. If "Qt5Gui"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
CMakeLists.txt:635 (include)

CMake Warning at cmake/OpenCVFindLibsGUI.cmake:20 (find_package):
By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"Qt5Widgets", but CMake did not find one.

Could not find a package configuration file provided by "Qt5Widgets" with
any of the following names:

Qt5WidgetsConfig.cmake
qt5widgets-config.cmake

Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set
"Qt5Widgets_DIR" to a directory containing one of the above files. If
"Qt5Widgets" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
CMakeLists.txt:635 (include)

CMake Warning at cmake/OpenCVFindLibsGUI.cmake:21 (find_package):
By not providing "FindQt5Test.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5Test", but
CMake did not find one.

Could not find a package configuration file provided by "Qt5Test" with any
of the following names:

Qt5TestConfig.cmake
qt5test-config.cmake

Add the installation prefix of "Qt5Test" to CMAKE_PREFIX_PATH or set
"Qt5Test_DIR" to a directory containing one of the above files. If
"Qt5Test" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
CMakeLists.txt:635 (include)

CMake Warning at cmake/OpenCVFindLibsGUI.cmake:22 (find_package):
By not providing "FindQt5Concurrent.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"Qt5Concurrent", but CMake did not find one.

Could not find a package configuration file provided by "Qt5Concurrent"
with any of the following names:

Qt5ConcurrentConfig.cmake
qt5concurrent-config.cmake

Add the installation prefix of "Qt5Concurrent" to CMAKE_PREFIX_PATH or set
"Qt5Concurrent_DIR" to a directory containing one of the above files. If
"Qt5Concurrent" provides a separate development package or SDK, be sure it
has been installed.
Call Stack (most recent call first):
CMakeLists.txt:635 (include)

qmake: could not exec '/usr/lib/aarch64-linux-gnu/qt4/bin/qmake': No such file or directory
CMake Error at /usr/share/cmake-3.10/Modules/FindQt4.cmake:1320 (message):
Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x
Call Stack (most recent call first):
cmake/OpenCVFindLibsGUI.cmake:34 (find_package)
CMakeLists.txt:635 (include)

Can you please tell me how to solve this?

Makefile:160: recipe for target 'all' failed

I installed Jetpack 3.0, and buildOpenCV.sh , but encouter the Makefile:160: recipe for target 'all' failed error. I don't if I lost some configuration or something else?

➜  buildOpenCVTX2 git:(master) ./buildOpenCV.sh
.................................................................
[ 11%] Linking CXX shared library ../../lib/libopencv_ml.so
[ 11%] Linking CXX shared library ../../lib/libopencv_cudaarithm.so
[ 11%] Linking CXX shared library ../../lib/libopencv_imgproc.so
[ 11%] Built target opencv_flann
[ 12%] Built target opencv_ml
[ 16%] Built target opencv_imgproc
[ 16%] Linking CXX shared library ../../lib/libopencv_cudawarping.so
[ 16%] Linking CXX shared library ../../lib/libopencv_video.so
[ 16%] Linking CXX shared library ../../lib/libopencv_imgcodecs.so
[ 19%] Built target opencv_cudaarithm
[ 19%] Built target opencv_video
[ 20%] Built target opencv_imgcodecs
[ 20%] Linking CXX shared library ../../lib/libopencv_cudabgsegm.so
[ 20%] Linking CXX shared library ../../lib/libopencv_cudafilters.so
[ 20%] Linking CXX shared library ../../lib/libopencv_shape.so
[ 20%] Built target opencv_cudawarping
[ 20%] Linking CXX shared library ../../lib/libopencv_videoio.so
CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_column_filter.32sc4.cu.o: file not recognized: File truncated
collect2: error: ld returned 1 exit status
modules/cudafilters/CMakeFiles/opencv_cudafilters.dir/build.make:6772: recipe for target 'lib/libopencv_cudafilters.so.3.2.0' failed
make[2]: *** [lib/libopencv_cudafilters.so.3.2.0] Error 1
CMakeFiles/Makefile2:2525: recipe for target 'modules/cudafilters/CMakeFiles/opencv_cudafilters.dir/all' failed
make[1]: *** [modules/cudafilters/CMakeFiles/opencv_cudafilters.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 20%] Built target opencv_cudabgsegm
[ 20%] Built target opencv_shape
[ 21%] Built target opencv_videoio
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
➜  buildOpenCVTX2 git:(master) 

camera open failed

First of all: Thanks for having all this stuff open-source:+1:

I have a TX2 with the latest JetPack 3.1 (L4T 28.1) and have uninstalled the preinstalled OpenCV version (sudo apt-get purge libopencv4tegra*). After that I installed OpenCV again using your script. That all worked!
The gstreamer_view.cpp works as well.

But if I run python cannyDetection.py I get

camera open failed

Any ideas?

videocapture error

Hi, when i use opencv Videocapture to open the camera ,it shows HIGHGUI ERROR:V4L2,pixel format of
incoming image is unsuppoted by OpenCV

opencv run error

I run opencv on my TX2.
Here is the error:

Does it mean that my TX2 without enough memory to run my program?

How can I fix it?

Thank you !!!

`---------------------------------------------------------------------------
error Traceback (most recent call last)
in ()
8 all_rect = []
9 sys.stdout.flush()
---> 10 work(imgdata, all_rect)
11 rectmap[imgid] = all_rect
12 result_annos = anno_func.get_refine_rects(annos, rectmap)

in work(imgdata, all_rect)
42 data = cv2.resize(imgdata, (data_layer.shape[2], data_layer.shape[3]))
43 else:
---> 44 data = cv2.resize(imgdata, (imgdata.shape[0]*resize, imgdata.shape[1]*resize))
45 data = data.transpose(2,0,1)
46 #print data.shape

error: OpenCV(3.4.1-dev) /home/nvidia/opencv/modules/core/src/alloc.cpp:55: error: (-4) Failed to allocate 1610612736 bytes in function OutOfMemoryError`

Build Error - OpenGL Support

Hey everyone,

i got an Issue while building the OpenCV based on your description. This could be an issue with the new Jetpack 3.2 and Cuda 9.0 because some OpenGL support in Cuda is broke.

If someone has the same problem, try the following which helped me:

Edit the file: "/usr/local/cuda-8.0/include/cuda_gl_interop.h"

Find the code:
#else /* __APPLE__ */

It should be around line 7.. then replace all the If Def's with the following to force include of GL/gl.h

#else /* __APPLE__ */
 
 #include <GL/gl.h>
 
 #endif /* __APPLE__ */

missing opencv.pc

After I build opencv the files are all there, but there is no opencv.pc file so I can't use pkg-config to find the libraries. I tried building it using the buildOpenCV.sh and installing the package created in buildAndPackageOpenCV.sh, but in both there is no opencv.pc file. I've look everywhere on my jetson, but the file isn't there.

OpenCV not compatible with YOLO

OpenCV 3.4.1 had build issues with C compilation mode, there is a new commit in the opencv github repo which solves this, but i am still getting the error

make
gcc -Iinclude/ -Isrc/ -DOPENCV pkg-config --cflags /usr/local/lib/pkgconfig/opencv.pc -DGPU -I/usr/local/cuda/include/ -DCUDNN -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -DGPU -DCUDNN -c ./src/gemm.c -o obj/gemm.o
In file included from /usr/local/include/opencv2/core/types_c.h:59:0,
from /usr/local/include/opencv2/core/core_c.h:48,
from /usr/local/include/opencv2/highgui/highgui_c.h:45,
from include/darknet.h:25,
from ./src/utils.h:5,
from ./src/gemm.c:2:
/usr/local/include/opencv2/core/cvdef.h:485:1: error: unknown type name ‘namespace’
namespace cv {
^
compilation terminated due to -Wfatal-errors.
Makefile:85: recipe for target 'obj/gemm.o' failed
make: *** [obj/gemm.o] Error 1

How to configure environment variables

Firstly ,thanks for your work
I have some question
when I complete the script , is it necessary to configure the environment variables for opencv ?
Is there any way to tell if cuda is accelerating opencv ?
Thanks again

Make fail. error: ‘NppiGraphcutState’ has not been declared

make -j6 and get error.

/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp: At global scope:
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declared
     typedef NppStatus (*init_func_t)(NppiSize oSize, NppiGraphcutState** ppState, Npp8u* pDeviceMem);
                                                      ^
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:135:18: error: ‘NppiGraphcutState’ does not name a type
         operator NppiGraphcutState*()
                  ^
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:141:9: error: ‘NppiGraphcutState’ does not name a type
         NppiGraphcutState* pState;
         ^
In file included from /home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/precomp.hpp:75:0,
                 from /home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:43:
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp: In constructor ‘{anonymous}::NppiGraphcutStateHandler::NppiGraphcutStateHandler(NppiSize, Npp8u*, {anonymous}::init_func_t)’:
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:127:39: error: ‘pState’ was not declared in this scope
             nppSafeCall( func(sznpp, &pState, pDeviceMem) );
                                       ^
/home/nvidia/buildOpenCVTX2/opencv/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
 #define nppSafeCall(expr)  cv::cuda::checkNppError(expr, __FILE__, __LINE__, CV_Func)
                                                    ^
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp: In destructor ‘{anonymous}::NppiGraphcutStateHandler::~NppiGraphcutStateHandler()’:
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:132:43: error: ‘pState’ was not declared in this scope
             nppSafeCall( nppiGraphcutFree(pState) );
                                           ^
/home/nvidia/buildOpenCVTX2/opencv/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
 #define nppSafeCall(expr)  cv::cuda::checkNppError(expr, __FILE__, __LINE__, CV_Func)
                                                    ^
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:132:49: error: ‘nppiGraphcutFree’ was not declared in this scope
             nppSafeCall( nppiGraphcutFree(pState) );
                                                 ^
/home/nvidia/buildOpenCVTX2/opencv/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
 #define nppSafeCall(expr)  cv::cuda::checkNppError(expr, __FILE__, __LINE__, CV_Func)
                                                    ^
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp: In function ‘void cv::cuda::graphcut(cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::Stream&)’:
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:174:51: error: ‘nppiGraphcutGetSize’ was not declared in this scope
     nppSafeCall( nppiGraphcutGetSize(sznpp, &bufsz) );
                                                   ^
/home/nvidia/buildOpenCVTX2/opencv/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
 #define nppSafeCall(expr)  cv::cuda::checkNppError(expr, __FILE__, __LINE__, CV_Func)
                                                    ^
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:182:61: error: ‘nppiGraphcutInitAlloc’ was not declared in this scope
     NppiGraphcutStateHandler state(sznpp, buf.ptr<Npp8u>(), nppiGraphcutInitAlloc);
                                                             ^
In file included from /home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/precomp.hpp:75:0,
                 from /home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:43:
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:191:146: error: ‘nppiGraphcut_32s8u’ was not declared in this scope
        static_cast<int>(terminals.step), static_cast<int>(leftTransp.step), sznpp, labels.ptr<Npp8u>(), static_cast<int>(labels.step), state) );
                                                                                                                                             ^
/home/nvidia/buildOpenCVTX2/opencv/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
 #define nppSafeCall(expr)  cv::cuda::checkNppError(expr, __FILE__, __LINE__, CV_Func)
                                                    ^
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:196:146: error: ‘nppiGraphcut_32f8u’ was not declared in this scope
        static_cast<int>(terminals.step), static_cast<int>(leftTransp.step), sznpp, labels.ptr<Npp8u>(), static_cast<int>(labels.step), state) );
                                                                                                                                             ^
/home/nvidia/buildOpenCVTX2/opencv/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
 #define nppSafeCall(expr)  cv::cuda::checkNppError(expr, __FILE__, __LINE__, CV_Func)
                                                    ^
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp: In function ‘void cv::cuda::graphcut(cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::Stream&)’:
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:246:52: error: ‘nppiGraphcut8GetSize’ was not declared in this scope
     nppSafeCall( nppiGraphcut8GetSize(sznpp, &bufsz) );
                                                    ^
/home/nvidia/buildOpenCVTX2/opencv/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
 #define nppSafeCall(expr)  cv::cuda::checkNppError(expr, __FILE__, __LINE__, CV_Func)
                                                    ^
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:254:61: error: ‘nppiGraphcut8InitAlloc’ was not declared in this scope
     NppiGraphcutStateHandler state(sznpp, buf.ptr<Npp8u>(), nppiGraphcut8InitAlloc);
                                                             ^
In file included from /home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/precomp.hpp:75:0,
                 from /home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:43:
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:267:146: error: ‘nppiGraphcut8_32s8u’ was not declared in this scope
        static_cast<int>(terminals.step), static_cast<int>(leftTransp.step), sznpp, labels.ptr<Npp8u>(), static_cast<int>(labels.step), state) );
                                                                                                                                             ^
/home/nvidia/buildOpenCVTX2/opencv/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
 #define nppSafeCall(expr)  cv::cuda::checkNppError(expr, __FILE__, __LINE__, CV_Func)
                                                    ^
/home/nvidia/buildOpenCVTX2/opencv/modules/cudalegacy/src/graphcuts.cpp:274:146: error: ‘nppiGraphcut8_32f8u’ was not declared in this scope
        static_cast<int>(terminals.step), static_cast<int>(leftTransp.step), sznpp, labels.ptr<Npp8u>(), static_cast<int>(labels.step), state) );
                                                                                                                                             ^
/home/nvidia/buildOpenCVTX2/opencv/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
 #define nppSafeCall(expr)  cv::cuda::checkNppError(expr, __FILE__, __LINE__, CV_Func)
                                                    ^
modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/build.make:2942: recipe for target 'modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/src/graphcuts.cpp.o' failed
make[2]: *** [modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/src/graphcuts.cpp.o] Error 1
CMakeFiles/Makefile2:5148: recipe for target 'modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/all' failed
make[1]: *** [modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

opencv with opencl

Hi,
Can we not build opencv with opencl support (ON) on the Jetson TX2 ??

I am unable to use opencvdnn on gpu .. hence wanted to use the opencl for gpu usage.

Any help would be great

Thanks

Jetson freezes when more than one videocapture is running.

This library has worked great for single videocapture but when I try to do 2 at the same time eventually my jetson freezes and stops responding to mouse and keyboard inputs. I posted an example usage of videocapture.
cv::VideoCapture cap1(pipeline1, cv::CAP_GSTREAMER);

JetPack 3.2

Should this be working with JetPack 3.2 (i.e. L4T 28.2 RC)? When I try, it builds OpenCV without CUDA support...

Installing OpenCV version 3.4.2 and above raise a python checking error

In case I'm trying to install OpenCV version 3.4.2 or 3.4.4 for example the Python checking which performed as the last step of the installation process is failed due to unresolved symbol "...dnn..." despite the fact that the cv2.so file was generated and the import cv2 command identify it.

Please advise.

skipping incompatible /usr/local/cuda/lib64/libcudnn.so when searching for -lcudnn

hi
i have manifod g2 (DJI pc) with:
jetson tx2
jetpack 3.2
cuda 9-0

i try to use dnn with cuda.
i try to compile opencv 4.5.1 with opencv_contrib:

  -D CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} \
  -D WITH_CUDA=ON \
  -D OPENCV_DNN_CUDA=ON \
  -D CUDNN_VERSION='9.0'\
  -D CUDA_ARCH_BIN=${ARCH_BIN} \
  -D CUDA_ARCH_PTX="" \
  -D ENABLE_FAST_MATH=ON \
  -D CUDA_FAST_MATH=ON \
  -D WITH_CUBLAS=ON \
  -D WITH_LIBV4L=ON \
  -D WITH_CUDNN=ON \
  -D WITH_GSTREAMER=ON \
  -D WITH_GSTREAMER_0_10=OFF \
  -D WITH_QT=ON \
  -D WITH_OPENGL=ON \
  -D OPENCV_EXTRA_MODULES_PATH=/home/nvidia/opencv_contrib/modules \
  -D BUILD_opencv_legacy=OFF \

In the building i get weird warring:
/usr/bin/ld: skipping incompatible /usr/local/cuda/lib64/libcudnn.so when searching for -lcudnn

and i get:

CMakeFiles/Makefile2:5082: recipe for target 'modules/dnn/CMakeFiles/opencv_dnn.dir/all' failed
make[1]: *** [modules/dnn/CMakeFiles/opencv_dnn.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

i do not know what to do ..

Updated version for Jetpack 3.2 with CUDA support

Hi,

It would be great if you are able to update the repository for Jetpack 3.2.
Is it also possible to provide a simple example showing cuda working with OpenCV?

Thanks for your great support!
Cheers,
Burak

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.