在python方式中,加载和显示图像非常简单。
import cv2
image = cv2.imread("path/to/image")
cv2.imshow("test window", image)
cv2.waitKey(0) # any key press will close the window and stop the program
在java中,它看起来像这样。
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Size;
类似于
其结果是在关闭和显示“视频结尾”之前,一个带有灰色图像的窗口持续约2秒。
import cv2
import imutils
vidPath = "filename.mp4"
video = cv2.VideoCapture(vidPath)
index = 0;
while True:
print (index)
index += 1
ret, frame = video.read()
if ret == False:
print("End of video")
break
我目前正在使用OPENCV在图像上绘制ROI: # Read image
im = cv2.imread(input_img)
# Select ROI
fromCenter = False
#Used to allow us to resize the windows.
cv2.namedWindow('PDF Scanner', cv2.WINDOW_NORMAL)
r = cv2.selectROI('PDF Scanner', im, fromCenter)
#Old version
我从Windows Server 2008r2中的计划任务启动Python脚本。脚本只生成发送到STDOUT的文本输出。CMD文件首先检查脚本是否已在运行,如果没有,则运行以下命令: start "Title Text for Window" python mypythonscript.py 这会导致脚本在固定大小的终端窗口中运行。它不能以交互方式调整大小,并且没有滚动条或回滚功能。 如果我运行CMD.EXE并输入python mypythonscript.py,我如何才能使脚本在相同类型的窗口中运行?我知道我可以在Python中更改窗口大小,但我希望它能像从交互式CMD窗口