img_paths = glob(r'D:\Project\CollegeDesign\dataset\BraTs3D\testImage\*')
时间: 2024-04-24 08:20:28 浏览: 108
引用是一个函数,用于获取指定路径下所有图片的文件名,并将文件名存储在一个列表中。具体代码如下:
```python
import os
def get_name(names):
path = 'Image/InPutImg/'
imagePaths = [os.path.join(path, f) for f in os.listdir(path)]
for imagePath in imagePaths:
name = str(os.path.split(imagePath)[1].split('.', 2))
names.append(name)
```
引用是一个使用OpenCV库对图片进行人脸检测并绘制矩形框的代码。具体代码如下:
```python
import cv2 as cv
img = cv.imread('Image/face1.jpg')
gary = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
face_detect = cv.CascadeClassifier(data.haarcascades + "haarcascade_frontalface_alt2.xml")
face = face_detect.detectMultiScale(gary)
for x, y, w, h in face:
cv.rectangle(img, (x, y), (x + w, y + h), color=(0, 0, 255), thickness=2)
cv.imshow('result', img)
```
阅读全文