Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

读取8位图报错 #114

Closed
dengfenglai321 opened this issue Nov 10, 2020 · 2 comments
Closed

读取8位图报错 #114

dengfenglai321 opened this issue Nov 10, 2020 · 2 comments

Comments

@dengfenglai321
Copy link

dengfenglai321 commented Nov 10, 2020

你好
运行det_train.py遇到位深度位8的图片会报错

遇到8位图时 im = cv2.imread(data['img_path'], 1 if self.img_mode != 'GRAY' else 0)
这句结果是None

cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-kne9u3r2/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

错误code位置:

    def __getitem__(self, index):
        # try:
        data = copy.deepcopy(self.data_list[index])
        print(data['img_path'])
        im = cv2.imread(data['img_path'], 1 if self.img_mode != 'GRAY' else 0)  
        if self.img_mode == 'RGB':
            im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)   #报错
        data['img'] = im
        data['shape'] = [im.shape[0], im.shape[1]]
        data = self.apply_pre_processes(data)

请问如何解决

@dengfenglai321 dengfenglai321 changed the title cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-kne9u3r2/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor' 读取8位图报错 Nov 10, 2020
@novioleo
Copy link
Collaborator

一般来说就是图像为空,烦请确认下这个地址的图像是否正常的哈~另外就是可能是图片格式不支持

@dengfenglai321
Copy link
Author

一般来说就是图像为空,烦请确认下这个地址的图像是否正常的哈~另外就是可能是图片格式不支持

解决了
图像是8位色素,opencv读出来就是none,但是PIL是可以读取的。。
遇到none跳过就好

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants