Python opencv 设置滑动窗口调节步长获得图像ROI并动态显示
2023-09-27 14:25:48 时间
def moveWindow(image, winWidth, winHeight):
height, width = image.shape[:2]
i_heiht = False
for i in range(0, height, 50):
if i + winHeight > height:
i_heiht = True
for j in range(0, width, 10):
showRecImage = image.copy()
if i + winHeight > height and j + winWidth > width:
moveRoi = image[i:height, j: width]
cv2.rectangle(showRecImage,(j, i), (width,height), (0, 0, 255), 1)
print("111")
break
elif j + winWidth > width:
moveRoi = image[i:winHeight + i, j: width]
cv2.rectangle(showRecImage, (j, i), ( width, winHeight + i), (0, 0, 255), 1)
print("222")
break
elif i + winHeight > height:
moveRoi = image[i: height , j: winWidth + j]
cv2.rectangle(showRecImage, (j, i), (winWidth + j, height), (0, 0, 255), 1)
print("333")
else:
moveRoi = image[i: winHeight+i, j: winWidth+j]
cv2.rectangle(showRecImage, (j, i), (winHeight+j, winWidth+i), (0, 0, 255), 1)
print("444")
print("i", i)
cv2.imshow("image", showRecImage)
cv2.waitKey(10)
if i_heiht:
break
if __name__ == "__main__":
image = cv2.imread("src.jpg")
# cv2.imshow("image", image)
# cv2.waitKey()
if image is None:
print("No images")
else:
moveWindow(image, 800, 800)
相关文章
- Python-OpenCV 图像与视频处理
- python中提示invalid syntax 总结
- python subprocess阻塞
- Python+selenium自动化元素定位防踩坑
- 【华为OD机试真题 python】完全二叉树非叶子部分后序遍历-2【2022 Q4 | 200分】
- 将OpenCV函数findContours()得到的每一个轮廓单独绘制并保存为图片文件的Python代码
- OpenCV-Python中的函数cv.imread()读取到的图像的数据存储结构是怎样的?
- 144 python网络编程 - UDP端口问题
- gyp ERR! stack Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.
- 【Python】监控笔记本电池状态
- 如何在OpenCV Python中翻转图像?
- OpenCV Python – 如何将彩色图像转换为二进制图像?
- 使用Python在OpenCV中使用haar Cascade的微笑检测
- Python代码库OpenCV之07图像处理和分割(含代码)
- Python代码库OpenCV之03读取和显示图片(含代码)
- Python代码库OpenCV之基础环境搭建(含代码)
- Python代码库OpenCV之12提取碑文文字并分割
- (数据科学学习手札11)K-means聚类法的原理简介&Python与R实现
- PIL 和 python-opencv 从内存字节码中读取图片并转为np.array格式
- Python——OpenCV计算机视觉库,功能介绍和应用
- 66、【链表】leetcode——142. 环形链表 II(C++、Python版本)
- 4、字符串——替换空格(python版)
- 小学生python游戏编程arcade----敌人自动面向角色并开火
- Python的数据库mongoDB的入门操作
- Java 调用Python+Opencv实现图片定位
- Python使用opencv实现图片定位第三种方式
- opencv python数据增强