dnn: add another color to Net::Impl::dump()#19035
dnn: add another color to Net::Impl::dump()#19035opencv-pushbot merged 1 commit intoopencv:masterfrom
Conversation
modules/dnn/src/dnn.cpp
Outdated
| } | ||
| } | ||
| string colors[] = {"#ffffb3", "#fccde5", "#8dd3c7", "#bebada", "#80b1d3", "#fdb462", "#ff4848", "#b35151"}; | ||
| string colors[] = {"#ffffb3", "#fccde5", "#8dd3c7", "#bebada", "#80b1d3", "#fdb462", "#ff4848", "#b35151", "#b662ff"}; |
There was a problem hiding this comment.
Does it make sense to replace to std::vector<std::string> and check colorId < colors.size()?
There was a problem hiding this comment.
btw, cppcheck found this here.
arent there static analyzers running over the code on the buildbots ?
There was a problem hiding this comment.
It's done time to time, but not for each PR.
47f9e9a to
83f45ae
Compare
83f45ae to
cf28b5e
Compare
| case DNN_TARGET_CUDA_FP16: out << "CUDA_FP16"; colorId = 6; break; | ||
| // don't use default: | ||
| } | ||
| CV_Assert(colorId < colors.size()); |
There was a problem hiding this comment.
BTW, this check can help in runtime only.
(no problem detection if there is no tests for this code)
There was a problem hiding this comment.
yes, i'd also rather favour something, that throws a compile time error instead.
unfortunately, all i could come up with is this:
enum X {A,B,C,D,MAX_X};
std::array<string,MAX_X> {"A","B","C","D","E"};
(works if there are excessive strings, but stays silent if there are not enough)
There was a problem hiding this comment.
If you want to add "MAX" value into enum then please use this approach to hide that from documentation:
https://github.com/opencv/opencv/blob/4.5.0/modules/calib3d/include/opencv2/calib3d.hpp#L474-L476
resolves #19034
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.