當前位置:首頁 » 編程語言 » python27formac

python27formac

發布時間: 2025-03-11 00:04:03

① 怎麼讓mac終端輸入python默認打開python3

首先得去Python官網下載mac版的Python 34並安裝。 安裝好了很簡單,在終端中輸入」python3″命令即可切換到Python 3版本,但是問題又來了,怎麼在終端中用Python 3運行py文件。 因為在終端輸入」python –version」顯示的始終是27的版本,即使輸入」怎麼讓mac終端輸入python默認打開python3

② mac本使用opencv打開攝像頭導致python意外退出

我再win上測試沒有問題,
import cv2
cap = cv2.VideoCapture(0)
while 1:
ret, frame = cap.read()
k = cv2.waitKey(1)
if k == 27:
break
cv2.imshow("capture", frame)
cap.release()
cv2.destroyAllWindows()
實在不行試試cv+pygame
代碼如下:
import pygame
import cv2

cap = cv2.VideoCapture(0)
ret, img = cap.read()
if not ret:
print("Can't read stream")

img = cv2.transpose(img)
print('shape:', img.shape)
pygame.init()
screen = pygame.display.set_mode((img.shape[0],img.shape[1]))
surface = pygame.surface.Surface((img.shape[0], img.shape[1]))
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
ret, img = cap.read()
if not ret:
running = False
break
else:
img = cv2.transpose(img)
pygame.surfarray.blit_array(surface, img)
screen.blit(surface, (0,0))

pygame.display.flip()
pygame.quit()

熱點內容
u3dandroid 發布:2025-03-11 03:22:41 瀏覽:356
ftp如何在網站上顯示圖片 發布:2025-03-11 03:17:41 瀏覽:929
不懂加工怎麼看數控車床配置 發布:2025-03-11 02:54:33 瀏覽:596
埋點系統存儲方案 發布:2025-03-11 02:41:20 瀏覽:442
編程要很久 發布:2025-03-11 02:41:10 瀏覽:196
筆記本電腦播放mp4時提醒伺服器運行失敗 發布:2025-03-11 02:40:32 瀏覽:441
吉利星瑞尊貴版配置有哪些 發布:2025-03-11 02:34:33 瀏覽:889
ecs中怎麼配置slb 發布:2025-03-11 02:33:17 瀏覽:719
vb圖片保存到資料庫 發布:2025-03-11 02:31:05 瀏覽:842
元件符號編譯器 發布:2025-03-11 02:30:12 瀏覽:74