被拉去参加一个没听过的奇奇怪怪的比赛,学习了一些奇奇怪怪的深度学习的东西,记录一下奇奇怪怪的事情
配合为巽大佬的文章食用更佳2024 年金砖竞赛 – 云边端赛项
环境相关
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. import 'atexit' >>>
|
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
|
pip install urllib3==1.26.16
pip install jupyterlab
pip install opencv-python
|
jupyter Lab自动补全
1. 安装jupyterlab-lsp
pip install jupyterlab-lsp pip install python-lsp-server
|
2. 开启自动补全
路径:Settings -> Advanced Settings Editor -> Notebook
{ "continuousHinting": true }
|
读取视频并抽帧
打开”com_rec/task1/collect/数据采集.ipynb”文件,完成以下任务:
1. 读取视频并查看视频信息
cap = cv2.VideoCapture(Video_path)
if cap.isOpened(): pass
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
2. 视频抽帧
ret,frame = cap.read()
cv2.imwrite("fame_{}".format(num),self.image)
cap.release() cv2.destoryAllWindows()
camera_th.Stop()
|
数据处理
打开”com_rec/task1/process/数据处理.ipynb”文件,完成以下任务
1. 完成系统OS模块使用
if os.path.exists("path")
filename_list = os.listdir(picture)
for filename in filename_list: filename.replace(".png", "jpg") os.rename(sourece_path, rename)
|
2.完成2.3图像颜色转换
imgbox_GARY = image[y_start, x_start,width,height]
image = cv2.imread(test.png)
image_GARY = cv2.cvtColor(iamge_GARY, COLOR_BGR2GRAY)
|
3. 完成2.4二值化处理
image = cv2.threshold(image_GARY, threshold, 255, cv2.THRESH_BINARY_INV)
|
4. 完成2.5图像边缘检测
image = imread(wuyanzu.png) image = imread(wuyanzu.png, cv2.IMREAD_GRAYSCALE)
end = cv2.Canny(image, 128, 200)
|
其他特别备注相关
cv2.waitKey(5)
time.sleep(0.005)
image = cv2.imread(path, cv2.IMREAD_GRAYSCALE)
|
基于给定评分细则和标准
数据采集
查看“camera.ipynb”代码块 1:
cv2.VideoCapture(camera_id)
cv2.imshow("image_win", image)
cv2.waitkey(5)
cv2.imwrite("image/image_{}.jpg".format(num), self.image)
|
查看“camera.ipynb”代码块 2:
camera_th = CameraThread(0, 640, 480)
camera_th.start()
|
查看“camera.ipynb”代码块 3:
camera_th.save_img(num)
camera_th.stop()
|
查看image文件夹
pass
数据特征提取
查看“process.ipynb”代码块 1:
M = cv2.getRotationMartix2D(center, angle, scale)
rotateg_img = cv2.warpAffine(img, M, (w, h))
img_num = len(img_list)
for img in img_list[:(img_num * 0.2)]:
rotated_img = rotate(img_data, -90)
cv2.imwtire(save_path, rotated_img)
pass
|
查看“processed”文件夹:文件夹内有 2 张图片文件
算法训练与性能评估
AI 应用系统开发
- 完成“2.2 人脸检测”: