我試圖寫一個保存圖像函數。預計下面的代碼將創建原始圖像的副本作爲saved-test-image.jpg。OpenCV-Python:img不是一個numpy數組,既不是一個標量
originalImage = "test-image.jpg"
savedImage = cv2.imwrite("saved-test-image.jpg",originalImage)
行的執行給follwing回:
Traceback (most recent call last):
File "UnitTest.py", line 159, in test_save_and_delete_image
savedImage = cv2.imwrite('unittest-images/saved-test-image.jpg', originalImage)
TypeError: img is not a numpy array, neither a scalar
什麼,這裏需要改變?
你應該首先'imread(..)'圖像。 –