英文:
Crash when reading bit map image in python
问题
使用以下代码块,我正在尝试读取并存储一个BMP图像,以便使用匹配算法进行图像处理。
print("starting read image function")
fimage = glob.glob("test.bmp")
incomingFingerprint = cv2.imread(fimage)
cv2.imwrite(fimage.replace('.bmp', '.jpg'), incomingFingerprint)
我发现我的代码崩溃,并在终端中打印了以下行:
进程以退出码 -1073740791 (0xC0000409) 结束
我想成功地读取并将图像存储在一个变量中,然后应用一些图像处理算法。
英文:
Using the following code block, I am trying to read and store a bmp image in order to make some image processing using a matching algorithm.
print("starting read image function")
fimage = glob.glob("test.bmp")
incomingFingerprint = cv2.imread(fimage)
cv2.imwrite(fimage.replace('.bmp', '.jpg'), incomingFingerprint)
I got my code crashed and printed this line in the terminal:
Process finished with exit code -1073740791 (0xC0000409)
I want to successfully read and store an image in a variable and then apply some image processing algorithms.
答案1
得分: 0
你错误地使用了 glob
— 它在输出时会给你一个列表。相反,只需将图像名称传递给 imread
和 imwrite
函数:
import cv2
incoming_fingerprint = cv2.imread('test.bmp')
cv2.imwrite('test.jpg', incoming_fingerprint)
英文:
You're incorrectly using glob
— it gives you a list on output. Instead, simply pass image name to the imread
and imwrite
functions:
import cv2
incoming_fingerprint = cv2.imread('test.bmp')
cv2.imwrite('test.jpg', incoming_fingerprint)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论