imwrite write on usb drive [closed]

asked 2019-03-18 16:04:36 -0600

lucacc gravatar image

updated 2019-03-19 03:47:18 -0600

Hi, I'm trying to write, in Python, an image on a USB drive using "imwrite" function. This is my code:

       _, img = camera.read()
       print("saved!")
       global img_counter
       img_name = "snapshot/opencv_frame_{}.png".format(img_counter)
       cv2.imwrite(img_name,img)

In this way I write an image in a folder. If I put:

  img_name = "/mnt/usbdrive/imgtest/opencv_frame_{}.png".format(img_counter)

like path (obviously after the mounting), the image is not saved on usb drive.

Any idea?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by lucacc
close date 2019-03-28 09:41:39.272221

Comments

broken indentation in the code above. (or -- what happens, if Camera.flags<=0 ?)

berak gravatar imageberak ( 2019-03-19 02:05:56 -0600 )edit

sorry, the code is a piece of entire program and It was very late when I wrote this post... Please look now...

lucacc gravatar imagelucacc ( 2019-03-19 03:48:17 -0600 )edit
  • Does img contain data in a 3 channel color format? If not, you'll need to convert the color format
  • Does img_counter have integer data in it from elsewhere in your program? if not, it needs to be initialized
  • Does the program/user have permissions to
    • access each element in the directory path /mnt/usbdrive/imgtest?
    • write the folder /mnt/usbdrive/imgtest?
    • create/write a file in /mnt/usbdribe/imgtest/<img_name>?
opalmirror gravatar imageopalmirror ( 2019-03-26 04:51:37 -0600 )edit