Ciclop开源3D扫描仪软件---Horus源码分析之Image_capture.py
来源:互联网 发布:mac口红美国价格 编辑:程序博客网 时间:2024/05/20 06:23
/****************************************************************************/
*
* (c) 光明工作室 2017-2037 COPYRIGHT
*
* 光明工作室团队成员大部分来自全国著名985、211工程院校。具有丰富的工程实践经验,
*本工作室热忱欢迎大家的光临。工作室长期承接嵌入式开发、PCB设计、算法仿真等软硬件设计。
*
*
*1)基于C8051、AVR、MSP430单片机开发。
*2)基于STM32F103、STM32F407等ARM处理器开发。(IIC、SPI、485、WIFI等相关设计)
*3)基于C6678、DM388等DSP处理器开发。(视频、网络、通信协议相关设计)
*4)基于QT、C#软件开发。
*5)基于OPENCV、OPENGL图像处理算法开发。(基于LINUX、WINDOWS、MATLAB等)
*6)无人机飞控、地面站程序开发。(大疆、PIX、 qgroundcontrol、missionplanner、MAVLINK)
*7) ROS机器人操作系统下相关开发。
*8)LINUX、UCOSII、VXWORKS操作系统开发。
*
*
* 联系方式:
* QQ:2468851091 call:18163325140
* Email:2468851091@qq.com
*
*
* (c) 光明工作室 2017-2037 COPYRIGHT
*
* 光明工作室团队成员大部分来自全国著名985、211工程院校。具有丰富的工程实践经验,
*本工作室热忱欢迎大家的光临。工作室长期承接嵌入式开发、PCB设计、算法仿真等软硬件设计。
*
*
*1)基于C8051、AVR、MSP430单片机开发。
*2)基于STM32F103、STM32F407等ARM处理器开发。(IIC、SPI、485、WIFI等相关设计)
*3)基于C6678、DM388等DSP处理器开发。(视频、网络、通信协议相关设计)
*4)基于QT、C#软件开发。
*5)基于OPENCV、OPENGL图像处理算法开发。(基于LINUX、WINDOWS、MATLAB等)
*6)无人机飞控、地面站程序开发。(大疆、PIX、 qgroundcontrol、missionplanner、MAVLINK)
*7) ROS机器人操作系统下相关开发。
*8)LINUX、UCOSII、VXWORKS操作系统开发。
*
*
* 联系方式:
* QQ:2468851091 call:18163325140
* Email:2468851091@qq.com
*
/ ****************************************************************************/
# -*- coding: utf-8 -*-# This file is part of the Horus Project__author__ = 'Jes煤s Arroyo Torrens <jesus.arroyo@bq.com>'__copyright__ = 'Copyright (C) 2014-2016 Mundo Reader S.L.'__license__ = 'GNU General Public License v2 http://www.gnu.org/licenses/gpl2.html'import cv2 ##导入OPENCV库存,因为三维扫描需要用到相机内参校正所以要用OPENCV.from horus import Singletonfrom horus.engine.driver.driver import Driver##导入驱动,这个驱动包括软件与硬件的所有引擎。因为本项目##还会有开源硬件。from horus.engine.calibration.calibration_data import CalibrationData##精度数据校正,这个库主要是对相机
##内部畸变参数进行校正。class CameraSettings(object): def __init__(self): self.driver = Driver() self.selected = False self.brightness = 0 self.contrast = 0 self.saturation = 0 self.exposure = 0 def set_brightness(self, value):##亮度 self.brightness = value if self.selected: self.driver.camera.set_brightness(value) def set_contrast(self, value):##对比度 self.contrast = value if self.selected: self.driver.camera.set_contrast(value) def set_saturation(self, value):##饱和度 self.saturation = value if self.selected: self.driver.camera.set_saturation(value) def set_exposure(self, value):##曝光度 self.exposure = value if self.selected: self.driver.camera.set_exposure(value) def send_all_settings(self):##图像各项数据发送 self.driver.camera.set_brightness(self.brightness) self.driver.camera.set_contrast(self.contrast) self.driver.camera.set_saturation(self.saturation) self.driver.camera.set_exposure(self.exposure)@Singletonclass ImageCapture(object): def __init__(self): self.driver = Driver() self.calibration_data = CalibrationData() self.texture_mode = CameraSettings() self.laser_mode = CameraSettings() self.pattern_mode = CameraSettings() self.stream = True self._mode = self.pattern_mode self._mode.selected = True self._remove_background = True self._updating = False self.use_distortion = False def initialize(self): self.texture_mode.initialize() self.laser_mode.initialize() self.pattern_mode.initialize() def set_flush_values(self, texture, laser, pattern): self._flush_texture = texture self._flush_laser = laser self._flush_pattern = pattern def set_flush_stream_values(self, texture, laser, pattern): self._flush_stream_texture = texture self._flush_stream_laser = laser self._flush_stream_pattern = pattern def set_use_distortion(self, value): self.use_distortion = value def set_remove_background(self, value): self._remove_background = value def set_mode(self, mode): if self._mode is not mode: self._updating = True self._mode.selected = False self._mode = mode self._mode.selected = True self._mode.send_all_settings() self._updating = False def set_mode_texture(self): self.set_mode(self.texture_mode) def set_mode_laser(self): self.set_mode(self.laser_mode) def set_mode_pattern(self): self.set_mode(self.pattern_mode) def flush_texture(self): self.set_mode_texture() self.capture_image(flush=0) def flush_laser(self): self.set_mode_laser() self.capture_image(flush=0) def flush_pattern(self): self.set_mode_pattern() self.capture_image(flush=0) def capture_texture(self): self.set_mode(self.texture_mode) if self.stream: flush = self._flush_stream_texture else: flush = self._flush_texture image = self.capture_image(flush=flush) return image def _capture_laser(self, index): self.set_mode(self.laser_mode) self.driver.board.lasers_off() self.driver.board.laser_on(index) if self.stream: flush = self._flush_stream_laser else: flush = self._flush_laser image = self.capture_image(flush=flush) self.driver.board.laser_off(index) return image def capture_laser(self, index): # Capture background image_background = None if self._remove_background: self.driver.board.lasers_off() if self.stream: flush = self._flush_stream_laser else: flush = self._flush_laser image_background = self.capture_image(flush=flush) # Capture laser image = self._capture_laser(index) if image_background is not None: if image is not None: image = cv2.subtract(image, image_background) return image def capture_lasers(self): # Capture background image_background = None if self._remove_background: self.driver.board.lasers_off() if self.stream: flush = self._flush_stream_laser else: flush = self._flush_laser image_background = self.capture_image(flush=flush) # Capture lasers images = [None, None] images[0] = self._capture_laser(0) images[1] = self._capture_laser(1) if image_background is not None: if images[0] is not None: images[0] = cv2.subtract(images[0], image_background) if images[1] is not None: images[1] = cv2.subtract(images[1], image_background) return images def capture_all_lasers(self): image_background = None self.set_mode(self.laser_mode) if self.stream: flush = self._flush_stream_laser else: flush = self._flush_laser if self._remove_background: self.driver.board.lasers_off() image_background = self.capture_image(flush=flush) self.driver.board.lasers_on() image = self.capture_image(flush=flush) self.driver.board.lasers_off() if image_background is not None: if image is not None and image_background is not None: image = cv2.subtract(image, image_background) return image def capture_pattern(self): self.set_mode(self.pattern_mode) if self.stream: flush = self._flush_stream_pattern else: flush = self._flush_pattern image = self.capture_image(flush=flush) return image def capture_image(self, flush=0): image = self.driver.camera.capture_image(flush=flush) if self.use_distortion: if image is not None and \ self.calibration_data.camera_matrix is not None and \ self.calibration_data.distortion_vector is not None and \ self.calibration_data.dist_camera_matrix is not None: image = cv2.undistort(image,##利用OPENCV内部函数校正数据。 self.calibration_data.camera_matrix, self.calibration_data.distortion_vector, None, self.calibration_data.dist_camera_matrix) return image
阅读全文
0 0
- Ciclop开源3D扫描仪软件---Horus源码分析之Image_capture.py
- Ciclop开源3D扫描仪软件---Horus源码分析之src\horus\engine\calibration\autocheck.py
- Ciclop开源3D扫描仪软件---Horus源码分析之src\horus\engine\calibration\calibration.py
- Ciclop开源3D扫描仪软件---Horus源码分析之src\horus\engine\calibration\calibration_data.py
- Ciclop开源3D扫描仪软件---Horus源码分析之src\horus\engine\calibration\camera_intrinsics.py
- Ciclop开源3D扫描仪软件---Horus源码分析之src\horus\engine\calibration\combo_calibration.py
- Ciclop开源3D扫描仪软件---Horus源码分析之src\horus\engine\calibration\laser_triangulation.py
- Ciclop开源3D扫描仪软件---Horus源码分析之src\horus\engine\calibration\moving_calibration.py
- Ciclop开源3D扫描仪软件---Horus源码分析之src\horus\engine\calibration\Pattern.py
- Ciclop开源3D扫描仪软件---Horus源码分析之src\horus\engine\calibration\platform_extrinsics.py
- Ciclop开源3D扫描仪软件---Horus源码分析之Image_detection.py
- Ciclop开源3D扫描仪软件---Horus源码分析之laser_segmentation.py
- Ciclop开源3D扫描仪软件---Horus源码分析之point_cloud_generation.py
- Ciclop开源3D扫描仪软件---Horus源码分析之point_cloud_roi.py
- Fuel 3D 扫描仪
- TensorFlow学习笔记之源码分析(3)---- retrain.py
- yolo源码分析之demo.py
- tushare 源码分析 之 fundamental.py
- Highly Available IP (HAIP) FAQ for Release 11.2
- Oracle中批量导出Sequence
- 安装Matlab_R2014A
- DW-HTML文件基本结构和基本标签
- 广东工业大学2017新生赛(决赛)-网络同步赛
- Ciclop开源3D扫描仪软件---Horus源码分析之Image_capture.py
- Spring REST
- url 请求get方式 为什么加 随机数作为参数
- HashMap1.8与HashMap1.6的不同
- DW-CSS简介
- 文件读写
- 2017年浙江工业大学大学生程序设计迎新赛热身赛 部分题解
- 蓝桥杯 算法提高 队列操作
- this指针