question

GarryMc-3626 avatar image
0 Votes"
GarryMc-3626 asked ramr-msft edited

DSVM Ubuntu 18.4 - OpenCV Broken

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-vm
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ramr-msft avatar image
0 Votes"
ramr-msft answered ramr-msft edited

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://docs.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



screenshot-147.png (42.7 KiB)
screenshot-149.png (56.8 KiB)
screenshot-148.png (1.5 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Well that's a long answer pity it ignored my question completely!


The sample you referenced was from 3 years ago, so it has little relevance to prove that it would work on the latest DSVM. As I stated (ok I had a slight typo but should still have been clear) I am already using the DSVM Ubuntu 18.04 image which was setup a few weeks ago. The sample code I provided DOES NOT WORK, however it SHOULD work.


Its clear that the OpenCV library has not been installed/configured correctly on this image. Can you please address my issue.


Note in my sample code where you see " its a quote, seems it was converted for some reason.


0 Votes 0 ·

Hi,
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

0 Votes 0 ·