2

I tested some code on my windows who worked perfectly. When exporting it on my VPS (Debian) I had some errors. Does it means it's not possible to make it work on linux at all (there's nothing I can do about it ?) ?

Here's what I found on the package page :

MacOS and Linux wheels have currently some limitations: 
- video related functionality is not supported (not compiled with FFmpeg)
- for example ``cv2.imshow()`` will not work (not compiled with GTK+ 2.x or Carbon support)

And here is the output error :

root@vps324173:~/Test# python main.py
 * Running on http://myserverip:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 296-193-487
myclientip - - [05/May/2017 04:33:52] "GET / HTTP/1.1" 200 -
a
OpenCV Error: Unknown error code -10 (Raw image encoder error: Empty JPEG image (DNL not supported)) in throwOnEror, file /io/opencv/modules/imgcodecs/src/grfmt_base.cpp, line 139
OpenCV Error: Unknown error code -10 (Raw image encoder error: Empty JPEG image (DNL not supported)) in throwOnEror, file /io/opencv/modules/imgcodecs/src/grfmt_base.cpp, line 139
Debugging middleware caught exception in streamed response at a point where response headers were already sent.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 704, in __next__
    return self._next()
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
    for item in iterable:
  File "/root/Test/main.py", line 14, in gen
    frame = camera.get_frame()
  File "/root/Test/camera.py", line 42, in get_frame
    ret, jpeg = cv2.imencode('.jpg', image)
error: /io/opencv/modules/imgcodecs/src/grfmt_base.cpp:139: error: (-10) Raw image encoder error: Empty JPEG image (DNL not supported) in function throwOnEror
myclientip - - [05/May/2017 04:33:52] "GET /video_feed HTTP/1.1" 200 -

Thanks for help !

2
  • What version of opencv do you have? Commented May 5, 2017 at 2:51
  • Hey. Thanks for your response. I'm using cv2 3.2.0. Commented May 5, 2017 at 12:37

1 Answer 1

2

You speak probably about opencv-python in pypi. This is very misleading project (often found in pypi, mature,..), probably useful for some pure OS with difficult opencv installation. Don't use it on Debian style Linux. To clarify it more:

  • python-opencv is Debian package (recommended, contains video support)
  • opencv-python is external project (not recommended, integrated opencv lacks video support)

so for Debian(,..) we have these possibilities:

install from Debian packages

sudo aptitude install libopencv-dev python-opencv
  # /usr/lib/python2.7/dist-packages/cv2.x86_64-linux-gnu.so
sudo aptitude purge libopencv-dev python-opencv  # uninstall

install from sources (github.com/opencv/opencv):

video support by default (for details see WITH_FFMPEG flag for cmake)

sudo aptitude install build-essential cmake
sudo aptitude install python-dev python-numpy
sudo aptitude install libavdevice-dev libavformat-dev libavfilter-dev libavcodec-dev libswscale-dev libavutil-dev 
sudo aptitude install libgtk2.0-common libgtk2.0-bin libgtk2.0-dev libdc1394-22-dev libv4l-dev libgstreamer-plugins-base1.0-dev
sudo pip install cmake
mkdir build/
cd build/
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
  # check output if FFMPEG status is YES
make
sudo make install --or-- sudo checkinstall --pkgname opencv
  # /usr/local/lib/python2.7/dist-packages/cv2.so
sudo make uninstall --or-- sudo dpkg -r opencv  # uninstall

opencv-python project (no need to use it!): opencv WITHOUT VIDEO support

sudo pip install opencv-python
  # /usr/local/lib/python2.7/dist-packages/cv2/cv2.so
sudo pip uninstall opencv-python  # uninstall

codec syntax:

try:
    codec = cv2.VideoWriter_fourcc(*'MJPG')   # newer syntax
except AttributeError:
    codec = cv2.cv.CV_FOURCC(*'MJPG')   # older syntax
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.