1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #26327 from asmorkalov:as/drop_convertFp16

Finally dropped convertFp16 function in favor of cv::Mat::convertTo() #26327 

Partially address https://github.com/opencv/opencv/issues/24909
Related PR to contrib: https://github.com/opencv/opencv_contrib/pull/3812

### 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
- [x] 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
This commit is contained in:
Alexander Smorkalov
2024-10-22 15:17:24 +03:00
committed by GitHub
parent a40ceff215
commit 9f0c3f5b2b
8 changed files with 26 additions and 231 deletions
+11 -3
View File
@@ -924,8 +924,16 @@ struct ConvertScaleFp16Op : public BaseElemWiseOp
void op(const vector<Mat>& src, Mat& dst, const Mat&)
{
Mat m;
convertFp16(src[0], m);
convertFp16(m, dst);
if (src[0].depth() == CV_32F)
{
src[0].convertTo(m, CV_16F);
m.convertTo(dst, CV_32F);
}
else
{
src[0].convertTo(m, CV_32F);
m.convertTo(dst, CV_16F);
}
}
void refop(const vector<Mat>& src, Mat& dst, const Mat&)
{
@@ -935,7 +943,7 @@ struct ConvertScaleFp16Op : public BaseElemWiseOp
{
// 0: FP32 -> FP16 -> FP32
// 1: FP16 -> FP32 -> FP16
int srctype = (nextRange & 1) == 0 ? CV_32F : CV_16S;
int srctype = (nextRange & 1) == 0 ? CV_32F : CV_16F;
return srctype;
}
void getValueRange(int, double& minval, double& maxval)