DSVM Ubuntu 18.4 - OpenCV Broken

Garry Mc 1 Reputation point
2020-05-22T00:49:42.75+00:00

DSVM: Ubuntu 18.4 - NC Series K80 VM

The following python code fails but should display an image (obviously need to change paths to suite to repro). This is causing me a lot of issues with samples I'm trying to run.

import cv2

image = cv2.imread("image1.jpg")

cv2.imshow("test", image)
cv3.waitKey(0)

CV2 is installed and will read the image data, but the show method fails, with the following error:

OpenCV(3.4.2) /tmp/build/80754af9/opencv-suite_1535558553474/work/modules/highgui/src/window.cpp:632: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
      File "/home/garrm/Desktop/PyImageSearch/SB_Code/chapter22-smile_detection/cv_test.py", line 5, in <module>
        cv2.imshow("test", image)

> Btw this form is terrible - I couldn't copy paste code in, I had to rewrite it.

Azure Data Science Virtual Machines
Azure Data Science Virtual Machines
Azure Virtual Machine images that are pre-installed, configured, and tested with several commonly used tools for data analytics, machine learning, and artificial intelligence training.
67 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ramr-msft 17,611 Reputation points
    2020-05-27T06:18:01.753+00:00

    There are two DSVM images on marketplace:- Please use the below links to create the same.

    1. Windows Server 2019 (Datacenter edition) DSVM - marketplace link
    2. Ubuntu Server 18.04 LTS DSVM - marketplace link

      https://learn.microsoft.com/en-us/azure/machine-learning/data-science-virtual-machine/tools-included
      8891-screenshot-149.png
      8892-screenshot-148.png

    Edited:
    OpenCV library is supported for Ubuntu Server 18.04 DSVM. Once the image is loaded using cv2, Instead of cv2.imshow() use the inline script to show the image. I have validated this on the VM:

     import cv2  
     import numpy as np  
     from matplotlib import pyplot as plt  
       
        
       
     img = cv2.imread('path_to_image.jpg',cv2.IMREAD_GRAYSCALE)  
       
        
       
     plt.imshow(img, cmap = 'gray', interpolation = 'bicubic')  
     plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis  
     plt.plot([200,300,400],[100,200,300],'c', linewidth=5)  
     plt.show()  
    

    Source of this info: https://stackoverflow.com/questions/14655969/opencv-error-the-function-is-not-implemented