Friendlier error messages when image path does not exist in cv2.seamlessClone() #20167#20617
Friendlier error messages when image path does not exist in cv2.seamlessClone() #20167#20617snehal2403 wants to merge 3 commits intoopencv:4.xfrom
Conversation
First imread was not showing error for invalid file path, Now it will throw an exception if the file path is invalid
|
There are several problems with this patch:
We assume that it is user's responsibility to distinguish between file-not-exists, access-denied and other failures. However, taking in account that many beginners have problems with this function I suggest adding a log message instead of throwing an exception: |
|
As mentioned above, proposed change breaks existed API - replacing returned value by exception. Check existed discussion in issues: #14095 |
…essClone() opencv#20167 This code will solve the problem. It will show the error if the file path supplied to seamlessclone() is invalid.
snehal2403
left a comment
There was a problem hiding this comment.
This code will solve the problem. It will show the error if the file path supplied to seamlessclone() is invalid.
| int dst_emp = _dst.empty(); | ||
| int mask_emp = _mask.empty(); | ||
| if (src_emp == 1) | ||
| cout << "Path of Source image is invalid" << endl; |
There was a problem hiding this comment.
Which path is mentioned here if frame data may come from the camera?
There in no "path" on algorithm implementation levels.
Unconditional using of cout is not allowed in cross-platform code.
This should be enough:
CV_Assert(!_src.empty());
There was a problem hiding this comment.
Okay thanks for your review. But here this code will check if the image read by imread() function is empty or not. Here no path is supplied to seamessclone() instead the parameters type is array.
This will solve the problem of showing Friendlier error messages when image path does not exist in cv2.seamlessClone().
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.