CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
DNN: Add New API blobFromImageParam #22750
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
Conversation
7b47836
to
e4abcec
Compare
60209c1
to
d280eab
Compare
Hi, the updated code has re-used old blobFromImage API, only change is convert scalefactor from
Is there any solution? |
a5c6ceb
to
520b472
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we have a new version with "parameters" do we really need to update old versions blobFromImage()
? We could deprecate them and suggest using a new variant.
You can generate extra overloads in Java with ManualFuncs option of Java bindigs generator. See modules/core/misc/java/gen_dict.json as example. Java tests for all manual functions are required. |
b80264b
to
716ba23
Compare
972d8ce
to
12acf76
Compare
blobFromImage
through New API blobFromImageParam
blobFromImage
through New API blobFromImageParam
Agree with @alalek. I propose that this PR only add new features to the new API |
12acf76
to
a58ce0c
Compare
edd832e
to
b8d1f84
Compare
6816dbd
to
5c0ed4f
Compare
b386d90
to
957cd82
Compare
957cd82
to
b4f6383
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@dkurt, can you please tell if "planar" layout used in TFLite importer is the same thing as "ND" layout used in other formats? |
Do we really need to introduce legacy TensorFlow NHWC data layout? I think it may introduce more confusion than strict NCHW input. Also, I'm not sure about preserving ratio during scale (crop/letter_box). They are different in different applications. For example, EfficientDet from TensorFlow: h, w = img.shape[0:2]
# 1. Resize and keep aspect ratio
assert(w >= h)
h = int(h / w * args.height)
inp = cv.resize(img.astype(np.float32), (args.width, h)) # It's important to perform resize for fp32
# 2. Zero padding to the bottom
inp = np.pad(inp, ((0, args.height - h), (0, 0), (0, 0)), 'constant')
inp = np.expand_dims(inp.transpose(2, 0, 1), axis=0)
@vpisarev, TFLite's planar is the same as TensorFlow's planar. It's used in case of 4D->3D or 2D reshaping when OpenCV data layout matches TensorFlow during import. |
a8c3f22
to
30aeda5
Compare
|
30aeda5
to
9450d87
Compare
Hi @asmorkalov, thanks for your reminder, updated. |
DNN: Add New API blobFromImageParam opencv#22750 The purpose of this PR: 1. Add new API `blobFromImageParam` to extend `blobFromImage` API. It can support the different data layout (NCHW or NHWC), and letter_box. 2. ~~`blobFromImage` can output `CV_16F`~~ ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
DNN: Add New API blobFromImageParam opencv#22750 The purpose of this PR: 1. Add new API `blobFromImageParam` to extend `blobFromImage` API. It can support the different data layout (NCHW or NHWC), and letter_box. 2. ~~`blobFromImage` can output `CV_16F`~~ ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
The purpose of this PR:
blobFromImageParam
to extendblobFromImage
API. It can support the different datalayout (NCHW or NHWC), and letter_box.blobFromImage
can outputCV_16F
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.