22 lines
462 B
Python
22 lines
462 B
Python
|
# -*- coding:utf-8 -*-
|
||
|
# @Author len
|
||
|
# @Create 2023/10/27 15:32
|
||
|
|
||
|
import cv2
|
||
|
|
||
|
# 读取图像
|
||
|
image = cv2.imread("trafficLight_yellow.png")
|
||
|
|
||
|
# 设定截取区域的坐标 (x, y, width, height)
|
||
|
x, y, w, h = 300, 30, 600, 180
|
||
|
|
||
|
# 截取图片
|
||
|
cropped_image = image[y:y+h, x:x+w]
|
||
|
|
||
|
# 保存截取的图片
|
||
|
cv2.imwrite("cropped_image_yellow.jpg", cropped_image)
|
||
|
|
||
|
# 显示结果
|
||
|
# cv2.imshow('Detected Red Light', cropped_image)
|
||
|
# cv2.waitKey(0)
|
||
|
# cv2.destroyAllWindows()
|