当前位置:首页 » 编程语言 » 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 浏览:930
不懂加工怎么看数控车床配置 发布:2025-03-11 02:54:33 浏览:597
埋点系统存储方案 发布:2025-03-11 02:41:20 浏览:443
编程要很久 发布:2025-03-11 02:41:10 浏览:196
笔记本电脑播放mp4时提醒服务器运行失败 发布:2025-03-11 02:40:32 浏览:441
吉利星瑞尊贵版配置有哪些 发布:2025-03-11 02:34:33 浏览:890
ecs中怎么配置slb 发布:2025-03-11 02:33:17 浏览:720
vb图片保存到数据库 发布:2025-03-11 02:31:05 浏览:843
元件符号编译器 发布:2025-03-11 02:30:12 浏览:74