1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 07:13:02 +04:00

Merge pull request #24539 from LaurentBerger:blobrecttoimage

Add blobrecttoimage #24539

### Pull Request Readiness Checklist

resolves https://github.com/opencv/opencv/issues/14659

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 #14659
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Laurent Berger
2023-12-19 18:00:04 +01:00
committed by GitHub
parent fa5ed62a66
commit 3e6dcdc0a4
4 changed files with 183 additions and 15 deletions
+28
View File
@@ -127,6 +127,34 @@ class dnn_test(NewOpenCVTests):
targets = cv.dnn.getAvailableTargets(cv.dnn.DNN_BACKEND_OPENCV)
self.assertTrue(cv.dnn.DNN_TARGET_CPU in targets)
def test_blobRectsToImageRects(self):
paramNet = cv.dnn.Image2BlobParams()
paramNet.size = (226, 226)
paramNet.ddepth = cv.CV_32F
paramNet.mean = [0.485, 0.456, 0.406]
paramNet.scalefactor = [0.229, 0.224, 0.225]
paramNet.swapRB = False
paramNet.datalayout = cv.dnn.DNN_LAYOUT_NCHW
paramNet.paddingmode = cv.dnn.DNN_PMODE_LETTERBOX
rBlob = np.zeros(shape=(20, 4), dtype=np.int32)
rImg = paramNet.blobRectsToImageRects(rBlob, (356, 356))
self.assertTrue(type(rImg[0, 0])==np.int32)
self.assertTrue(rImg.shape==(20, 4))
def test_blobRectToImageRect(self):
paramNet = cv.dnn.Image2BlobParams()
paramNet.size = (226, 226)
paramNet.ddepth = cv.CV_32F
paramNet.mean = [0.485, 0.456, 0.406]
paramNet.scalefactor = [0.229, 0.224, 0.225]
paramNet.swapRB = False
paramNet.datalayout = cv.dnn.DNN_LAYOUT_NCHW
paramNet.paddingmode = cv.dnn.DNN_PMODE_LETTERBOX
rBlob = np.zeros(shape=(20, 4), dtype=np.int32)
rImg = paramNet.blobRectToImageRect((0, 0, 0, 0), (356, 356))
self.assertTrue(type(rImg[0])==int)
def test_blobFromImage(self):
np.random.seed(324)