1

Hi I am learning opencv and the last part of the code, where I use the function cv2imwrite to save the processed image doesn't show up on any directory. Here is the code:

   # Canny Edge Detection

edges = cv2.Canny(image=img_blur, threshold1=100, threshold2=200) 

    # Saves Canny Edge Detection Image

cv2.imwrite('C:/Users/Gordenbúh/OneDrive/Escritorio/Hispatec/NaranjasCanny.png', edges)

cv2.waitKey(0)

cv2.destroyAllWindows()
    
    #This last part is to destroy some other images that I want to see but not keep

So the script runs fine, and I can see the image if I use cv2.imshow.

Thank you,

F

ti7
  • 16,375
  • 6
  • 40
  • 68
Gordenbúh
  • 25
  • 1
  • 7
  • does it raise an Exception? – ti7 Jan 20 '22 at 00:33
  • Try saving to your hard drive and not a cloud drive. – fmw42 Jan 20 '22 at 00:55
  • 1
    A couple of observations (assuming that path actually exists): non-ascii characters in a path is never a good idea. Now, backslashes have special meaning in string literals, if you want to use one you need to escape it: `'C:\\Users\\Gordenbúh\\OneDrive\\Escritorio\\Hispatec\\NaranjasCanny.png'`. Also, `cv2.imwrite` returns a `bool` indicating if the write operation was successful or not, consider using that to check possible write errors. – stateMachine Jan 20 '22 at 01:25
  • the issue is `imwrite` and imread have issues with umlauts and other "weird" characters. I see that in the given path. – Christoph Rackwitz Jan 20 '22 at 08:14
  • Does this answer your question? [opencv imread() on Windows for non-ASCII file names](https://stackoverflow.com/questions/24769623/opencv-imread-on-windows-for-non-ascii-file-names) – Christoph Rackwitz Jan 20 '22 at 08:15
  • This path "C:/Users/Gordenbúh/OneDrive/Escritorio/Hispatec" is valid? Have you ever created this directory? – Viettel Solutions Jan 27 '22 at 02:34

0 Answers0