html 输入框并行,Python:输入文本框并行捕获userinput到OpenCV Live网络摄像头图像...
我有一個簡單的腳本運行流式傳輸我的網絡攝像頭的圖像,我想做一些像canny-filter和hough轉換一樣的操作來檢測liveimage中的行:Python:輸入文本框并行捕獲userinput到OpenCV Live網絡攝像頭圖像
import cv2
import math
# Init
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame1',frame)
cv2.imshow('frame2',gray)
cv2.moveWindow('frame1', 200, 10)
cv2.moveWindow('frame2', 200+660, 10)
# (3.)
edges = cv2.Canny(frame, 40, 100)
cv2.imshow('lines',edges)
cv2.moveWindow('lines', 200, 10+530)
# hough
lines = cv2.HoughLinesP(edges, 1, math.pi/2, 20, None, 100, 10)
edgeimg = gray
if not lines is None:
for line in lines[0]:
pt1 = (line[0],line[1])
pt2 = (line[2],line[3])
cv2.line(edgeimg, pt1, pt2, (255,0,0), 3)
cv2.imshow('hough',edgeimg)
cv2.moveWindow('hough', 200+660, 10+530)
# cv2.imshow('img',img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
的問題是,我需要微調精明的過濾器和霍夫,函數的參數,因此我想做出一些輸入框平行于liveimage窗口運行在那里我可以輸入這些值。
我想到了最簡單的解決方案,可以減少編碼開銷,從而選擇tkinter。但是我很難同時運行tkinter-box(只能從這里找到這個解決方案:How do you run your own code alongside Tkinter's event loop?),這使得當我使用來自帖子#1的代碼并將我的liveimage功能task。
你能告訴我一個簡單的解決方案,顯示輸入框,用戶可以在其中輸入用作Canny/houghlines參數的數字嗎?
謝謝
2014-01-06
tim
+2
你可以使用opencv附帶的滑塊嗎?有限,因為它們工作得很好 –
+0
啊我想知道它們是否可用于cv2,因為我在文檔中看不到它們:http://docs.opencv.org/modules/highgui/doc/ user_interface.html#createtrackbar為什么它們不可用?是要導入舊的opencv版本,如'import cv2.cv as cv',然后通過'cv.CreateTrackbar(..)'命令使用它? –
+0
噢,謝謝,它就像一個魅力!精彩。你還能向我解釋為什么opencv中的一些命令只能通過* old *'cv'訪問,而沒有移植到cv2?我只是想知道.. –
總結
以上是生活随笔為你收集整理的html 输入框并行,Python:输入文本框并行捕获userinput到OpenCV Live网络摄像头图像...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 思岚科技亮相工博会,加速技术下沉,赋能产
- 下一篇: 微机原理-04-指令系统