error: (-2:Unspecified error) could not find a writer for the specified extension in function cv::imwrite

asked 2020-08-11 12:24:11 -0600

updated 2020-08-11 20:20:20 -0600

supra56 gravatar image

'''prediciton using distance'''

for embedding in embeds:
     diff = np.subtract(saved_embeds, embedding)
     dist = np.sum(np.square(diff), 1)
     idx = np.argmin(dist)
     if dist[idx] < threshold:
          predictions.append(names[idx])
          cv2.imwrite(names[idx],frame)

why the image is not saved ?? getting this error :

error: OpenCV(4.3.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-b460jg4o\opencv\modules\imgcodecs\src\loadsave.cpp:667: error: (-2:Unspecified error) could not find a writer for the specified extension in function 'cv::imwrite_'
edit retag flag offensive close merge delete

Comments

what is actually unclear about the error msg to you ?

what is in names[idx] ?

(it probably cannot resolve a file extension from there)

berak gravatar imageberak ( 2020-08-11 12:46:14 -0600 )edit

You are missing the extension for jpg, png etc for names[idx]

supra56 gravatar imagesupra56 ( 2020-08-11 20:25:40 -0600 )edit