Repository: opencv
Issue: FaceDetectorYN return NoneType object when not detected faces
Labels: bug,category: objdetect,RFC

<!--
If you have a question rather than reporting a bug please go to https://forum.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->

##### System information (version)
<!-- Example
- OpenCV => 4.2
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2017
-->

- OpenCV => 4.5.4
- Operating System / Platform => Windows 10 64 Bit
- Compiler => Python 3.8

##### Detailed description
<!-- your description -->

[FaceDetectorYN](https://docs.opencv.org/4.5.4/df/d20/classcv_1_1FaceDetectorYN.html) will return NoneType object when not detected faces in image.
I think it should return empty np.array instead of NoneType object.
@fengyuentau What do you think?

In the case of return is NoneType object, users need to check valid before accessing results. It is not user-friendly.
```python
# face detection
_, faces = face_detector.detect(image)
#print(dtype(faces)) # detect: <class 'numpy.ndarray'>, not detect: <class 'NoneType'>

# need check valid
if faces is not None:
    # get bounding box
    for face in faces:
        box = list(map(int, face[:4]))
        pritn(box)

# if get bounding box without check valid, occure error when not detected faces in image.
# TypeError: 'NoneType' object is not subscriptable in this line. 
for face in faces:
    box = list(map(int, face[:4]))
    pritn(box)
```

In the case of return is empty np.array, users accessing results without valid check.
```python
# face detection
_, faces = face_detector.detect(image)
#print(dtype(faces)) # allways: <class 'numpy.ndarray'>

# get bounding box
for face in faces:
    box = list(map(int, face[:4]))
    pritn(box)
```

By the way, [DetectionModel](https://docs.opencv.org/4.5.4/d3/df1/classcv_1_1dnn_1_1DetectionModel.html) will return empty np.array. Therefor, it is not necessary to check valid. It is simple.
```python
# object detection
confidence_threshold = 0.3
nms_threshold = 0.4
_, _, boxes = detection_model.detect(image, confidence_threshold, nms_threshold)
print(dtype(boxes)) # allways: <class 'numpy.ndarray'>

# get bounding box
for box in boxes:
    pritn(box)
```

##### Steps to reproduce
<!-- to add code example fence it with triple backticks and optional file extension
    ```.cpp
    // C++ code example
    ```
 or attach as .txt or .zip file
-->
Here is the simple code that can reproduce this problem. You can download model from [here](https://docs.opencv.org/4.5.4/d0/dd4/tutorial_dnn_face.html).
```python
import numpy as np
import cv2 as cv

# create face detector
face_detector = cv.FaceDetectorYN_create("yunet.onnx", "", (0, 0))

# create image without faces
image = np.zeros((512, 512, 3), dtype=np.uint8)

# face detection
height, width, _ = image.shape
face_detector.setInputSize((width, height))
_, faces = face_detector.detect(image)

# get bounding box
for face in faces: # error : TypeError: 'NoneType' object is not subscriptable in this line. 
    box = list(map(int, face[:4]))
    pritn(box)
```

##### Issue submission checklist

 - [x] I report the issue, it's not a question
   <!--
   OpenCV team works with forum.opencv.org, Stack Overflow and other communities
   to discuss problems. Tickets with question without real issue statement will be
   closed.
   -->
 - [x] I checked the problem with documentation, FAQ, open issues,
       forum.opencv.org, Stack Overflow, etc and have not found solution
   <!--
   Places to check:
   * OpenCV documentation: https://docs.opencv.org
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ
   * OpenCV forum: https://forum.opencv.org
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
   -->
 - [x] I updated to latest OpenCV version and the issue is still there
   <!--
   master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
   OpenCV team supports only latest release for each branch.
   The ticket is closed, if the problem is not reproduced with modern version.
   -->
 - [x] There is reproducer code and related data files: videos, images, onnx, etc
   <!--
   The best reproducer -- test case for OpenCV that we can add to the library.
   Recommendations for media files and binary files:
   * Try to reproduce the issue with images and videos in opencv_extra repository
     to reduce attachment size
   * Use PNG for images, if you report some CV related bug, but not image reader
     issue
   * Attach the image as archive to the ticket, if you report some reader issue.
     Image hosting services compress images and it breaks the repro code.
   * Provide ONNX file for some public model or ONNX file with with random weights,
     if you report ONNX parsing or handling issue. Architecture details diagram
     from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
   -->