赞
踩
- import camera
- import struct
- import time
-
- ####分辨率范围####
- # FRAME_96X96 - 96x96 像素
- # FRAME_QQVGA - 160x120 像素 (QQVGA代表Quarter Quarter VGA)
- # FRAME_QCIF - 176x144 像素 (QCIF代表Quarter CIF)
- # FRAME_HQVGA - 240x160 像素 (HQVGA代表Half Quarter VGA)
- # FRAME_240X240 - 240x240 像素
- # FRAME_QVGA - 320x240 像素 (QVGA代表Quarter VGA)
- # FRAME_CIF - 352x288 像素 (CIF代表Common Intermediate Format)
- # FRAME_HVGA - 480x320 像素 (HVGA代表Half VGA)
- # FRAME_VGA - 640x480 像素 (VGA代表Video Graphics Array)
- # FRAME_SVGA - 800x600 像素 (SVGA代表Super VGA)
- # FRAME_XGA - 1024x768 像素 (XGA代表Extended Graphics Array)
- # FRAME_HD - 1280x720 像素 (HD代表High Definition)
- # FRAME_SXGA - 1280x1024 像素 (SXGA代表Super XGA)
- # FRAME_UXGA - 1600x1200 像素 (UXGA代表Ultra XGA)
- # FRAME_FHD - 1920x1080 像素 (FHD代表Full High Definition)
- # FRAME_P_HD - 1600x1200 像素 (P_HD代表Partial High Definition)
- # FRAME_P_3MP - 2048x1536 像素 (P_3MP代表Partial 3 Megapixels)
- # FRAME_QXGA - 2048x1536 像素 (QXGA代表Quad Extended Graphics Array)
- # FRAME_QHD - 2560x1440 像素 (QHD代表Quad High Definition)
- # FRAME_WQXGA - 2560x1600 像素 (WQXGA代表Wide Quad Extended Graphics Array)
- # FRAME_P_FHD - 2560x1600 像素 (P_FHD代表Partial Full High Definition)
- # FRAME_QSXGA - 2560x2048 像素 (QSXGA代表Quad Super XGA)
-
- if __name__ != '_main_':
- try:
- camera.init(0, format=camera.JPEG,framesize=camera.FRAME_XGA)
- except Exception as e:
- camera.deinit()
- camera.init(0, format=camera.JPEG,framesize=camera.FRAME_XGA)
- time.sleep_ms(500)
- ## Other settings:
- # flip up side down
- camera.flip(1)
- # left / right
- camera.mirror(1)
- time.sleep_ms(200)
- # framesize
- #camera.framesize(camera.FRAME_240X240)
- # The options are the following:
- # FRAME_96X96 FRAME_QQVGA FRAME_QCIF FRAME_HQVGA FRAME_240X240
- # FRAME_QVGA FRAME_CIF FRAME_HVGA FRAME_VGA FRAME_SVGA
- # FRAME_XGA FRAME_HD FRAME_SXGA FRAME_UXGA FRAME_FHD
- # FRAME_P_HD FRAME_P_3MP FRAME_QXGA FRAME_QHD FRAME_WQXGA
- # FRAME_P_FHD FRAME_QSXGA
- # Check this link for more information: https://bit.ly/2YOzizz
-
- # special effects
- camera.speffect(camera.EFFECT_NONE)
- # The options are the following:
- # EFFECT_NONE (default) EFFECT_NEG EFFECT_BW EFFECT_RED EFFECT_GREEN EFFECT_BLUE EFFECT_RETRO
-
- # white balance
- camera.whitebalance(camera.WB_NONE)
- # The options are the following:
- # WB_NONE (default) WB_SUNNY WB_CLOUDY WB_OFFICE WB_HOME
-
- # saturation
- camera.saturation(0)
- # -2,2 (default 0). -2 grayscale
-
- # brightness
- camera.brightness(0)
- # -2,2 (default 0). 2 brightness
-
- # contrast
- camera.contrast(0)
- #-2,2 (default 0). 2 highcontrast
-
- # quality
- camera.quality(10)
- # 10-63 lower number means higher quality
-
- print("摄像头初始化完成。")
-
- # 获取图像数据流示例
- # buffer = camera.capture() #图像数据
以下是摄像头控制的一些常见 API 函数、中文名称和使用方式的简要列表:
函数 | 名称 | 使用方式 |
camera.init() | 初始化摄像头 | camera.init(0, format=camera.JPEG) # JPEG -- 3 |
camera.deinit() | 关闭摄像头 | camera.deinit() |
camera.framesize() | 设置摄像头分辨率 | camera.framesize(camera.FRAME_240X240)
|
camera.capture() | 拍摄照片并保存 | buffer = camera.capture() #获取图像数据 |
camera.brightness() | 设置摄像头亮度 | camera.brightness(0) # -2,2 (default 0) |
camera.contrast() | 设置摄像头对比度 | camera.contrast(0) # -2,2 (default 0) |
camera.whitebalance() | 设置摄像头白平衡 | camera.whitebalance(camera.
|
camera.saturation() | 设置摄像头饱和度 | camera.saturation(0) # -2,2 (default 0) |
camera.speffect() | 设置摄像头滤镜 | camera.binning(
|
camera.mirror() | 设置摄像头镜像效果 | camera.mirror(1) # 0,1 |
camera.flip() | 设置摄像头旋转 | camera.flip(1) # 0,1 |
camera.quality() | 摄像质量 | camera.quality(10) # 10-63 数字越低意味着质量越高 |
这只是一些常见的摄像头控制 API 函数示例,实际的摄像头库可能具有更多其他功能和选项。确保查阅摄像头库的官方文档以获取更详细的信息和使用方式。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。