-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from rogy-AquaLab/camera_reader_python
camera_readerをc++からpythonに変更
- Loading branch information
Showing
10 changed files
with
72 additions
and
108 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import rclpy | ||
from rclpy.node import Node | ||
from sensor_msgs.msg import Image | ||
import cv2 | ||
from cv_bridge import CvBridge | ||
|
||
|
||
class Camera(Node): | ||
def __init__(self): | ||
super().__init__('camera') | ||
self.publisher_=self.create_publisher(Image, 'camera_image', 10) | ||
self.timer=self.create_timer(0.1, self.timer_callback) | ||
self.cap=cv2.VideoCapture(0) | ||
self.bridge=CvBridge() | ||
if not self.cap.isOpened(): | ||
self.get_logger().error('Failed to open camera') | ||
rclpy.shutdown() | ||
|
||
def timer_callback(self): | ||
ret,frame=self.cap.read() | ||
if ret: | ||
msg=self.bridge.cv2_to_imgmsg(frame, "bgr8") | ||
self.publisher_.publish(msg) | ||
else: | ||
self.get_logger().error('Failed to capture image') | ||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
camera=Camera() | ||
rclpy.spin(camera) | ||
camera.destroy_node() | ||
rclpy.shutdown() | ||
|
||
if __name__=="__main__": | ||
main() |
17 changes: 0 additions & 17 deletions
17
device/camera_reader/include/camera_reader/camera_reader.hpp
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,21 +3,15 @@ | |
<package format="3"> | ||
<name>camera_reader</name> | ||
<version>0.0.0</version> | ||
<description>ROS 2 package for receiving images</description> | ||
<maintainer email="[email protected]">hiro</maintainer> | ||
<description>Camera</description> | ||
<maintainer email="[email protected]">hiro</maintainer> | ||
<license>MIT License</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<build_depend>rclcpp</build_depend> | ||
<build_depend>sensor_msgs</build_depend> | ||
<build_depend>cv_bridge</build_depend> | ||
<build_depend>image_transport</build_depend> | ||
<exec_depend>rclcpp</exec_depend> | ||
<exec_depend>rclpy</exec_depend> | ||
<exec_depend>sensor_msgs</exec_depend> | ||
<exec_depend>cv_bridge</exec_depend> | ||
<exec_depend>image_transport</exec_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
<build_type>ament_python</build_type> | ||
</export> | ||
</package> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[develop] | ||
script_dir=$base/lib/camera_reader | ||
[install] | ||
install_scripts=$base/lib/camera_reader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
from glob import glob | ||
|
||
from setuptools import find_packages, setup | ||
|
||
package_name = 'camera_reader' | ||
|
||
setup( | ||
name=package_name, | ||
version='0.0.0', | ||
packages=[package_name], | ||
data_files=[ | ||
('share/ament_index/resource_index/packages',['resource/' + package_name]), | ||
('share/' + package_name,['package.xml']), | ||
(os.path.join('share','package_name','launch'),glob(os.path.join('launch','*'))) | ||
], | ||
install_requires=['setuptools'], | ||
zip_safe=True, | ||
maintainer='hiro', | ||
maintainer_email='[email protected]', | ||
description='Camera for ROS2', | ||
license='MIT license', | ||
tests_require=[], | ||
entry_points={ | ||
'console_scripts': [ | ||
'camera=camera_reader.camera:main', | ||
], | ||
}, | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.