RuntimeError using cv.SaveImage in openCV

From Python CV documentation, the CV2 method for converting a jpeg to png is: Python: cv2.imwrite(filename, img[, params]) → retval

For my example:

import cv2
filename = 'pic.jpeg'
cam = cv2.VideoCapture(filename)
s, img = cam.read()
picName = 'pic.png'
cv2.imwrite(picName, img)

VideoCapture is nice and general, and works with videos, webcams and image files.


The best choice is pyopencv:

import pyopencv as cv

img = cv.imread('01.png')

cv.imshow('img-windows',img)
cv.waitKey(0)
cv.imwrite('01.png',img)

I solved the problem, the image I took randomly from the Google Images doesn't load. Maybe it's encrypted or something I don't know. I tried it with other images, and worked very well. So watch out while copying images : )

Tags:

Python

Opencv