Skip to content

Commit ef2c410

Browse files
initial code commit
0 parents  commit ef2c410

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed

CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cmake_minimum_required(VERSION 2.4.6)
2+
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
3+
4+
# Set the build type. Options are:
5+
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage
6+
# Debug : w/ debug symbols, w/o optimization
7+
# Release : w/o debug symbols, w/ optimization
8+
# RelWithDebInfo : w/ debug symbols, w/ optimization
9+
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
10+
#set(ROS_BUILD_TYPE RelWithDebInfo)
11+
catkin_package()
12+
rosbuild_init()
13+
14+
#set the default path for built executables to the "bin" directory
15+
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
16+
#set the default path for built libraries to the "lib" directory
17+
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
18+
19+
#uncomment if you have defined messages
20+
#rosbuild_genmsg()
21+
#uncomment if you have defined services
22+
#rosbuild_gensrv()
23+
24+
#common commands for building c++ executables and libraries
25+
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
26+
#target_link_libraries(${PROJECT_NAME} another_library)
27+
#rosbuild_add_boost_directories()
28+
#rosbuild_link_boost(${PROJECT_NAME} thread)
29+
#rosbuild_add_executable(example examples/example.cpp)
30+
#target_link_libraries(example ${PROJECT_NAME})

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include $(shell rospack find mk)/cmake.mk

launch/boson.launch

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<launch>
2+
<node pkg="capture_boson" name="camera" type="grabber.py" output="screen" />
3+
<node pkg="topic_tools" name="throttler" type="throttle" args="messages /image 15 /image_throttle" />
4+
<node pkg="image_capture" name="writer" type="writer.py" output="screen">
5+
<remap from="image" to="image_throttle" />
6+
</node>
7+
</launch>

package.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<package format="2">
2+
<name>boson</name>
3+
<version>0.1.0</version>
4+
<description brief="boson">
5+
This package provides foo capability.
6+
</description>
7+
<maintainer email="[email protected]">Josh Veitch-Michaelis</maintainer>
8+
<license>GPL</license>
9+
10+
<buildtool_depend>catkin</buildtool_depend>
11+
12+
<depend>rospy</depend>
13+
<depend>std_msgs</depend>
14+
<depend>sensor_msgs</depend>
15+
<depend>cv_bridge</depend>
16+
17+
<exec_depend>rospy</exec_depend>
18+
19+
</package>

scripts/capture.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/python
2+
3+
import roslib
4+
roslib.load_manifest("boson")
5+
import sys
6+
import rospy
7+
import cv2
8+
import time
9+
from std_msgs.msg import String
10+
from sensor_msgs.msg import Image
11+
from cv_bridge import CvBridge, CvBridgeError
12+
import numpy as np
13+
14+
def write_buffer(filename, buffer):
15+
t = time.time()
16+
np.save(filename, buffer)
17+
#print("Saved in {}".format(time.time()-t), filename)
18+
19+
def main(args):
20+
rospy.init_node("camera", anonymous=True)
21+
image_pub = rospy.Publisher("image",Image, queue_size=10)
22+
23+
bridge = CvBridge()
24+
25+
cap = cv2.VideoCapture(0 + cv2.CAP_V4L2)
26+
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc(*"Y16 "))
27+
cap.set(cv2.CAP_PROP_CONVERT_RGB, False)
28+
29+
buffer_size = 100
30+
buffer = np.zeros((buffer_size,512,640), dtype='uint16')
31+
32+
i = 0
33+
j = 0
34+
35+
while not rospy.is_shutdown():
36+
t = time.time()
37+
res, image = cap.read()
38+
if res:
39+
image_pub.publish(bridge.cv2_to_imgmsg(image, encoding="passthrough"))
40+
#cv2.imwrite("/boson_ws/captures/image_{}.tiff".format(i), image)
41+
42+
buffer[i] = image
43+
i += 1
44+
45+
if i == buffer_size:
46+
#print("Writing")
47+
#filename = "/boson_ws/captures/buffer_{}".format(j)
48+
#np.save(filename, buffer)
49+
#buffer, buffer_double = buffer_double, buffer
50+
i = 0
51+
j += 1
52+
53+
#print "FPS", 1.0/(time.time()-t)
54+
55+
56+
cap.release()
57+
58+
if __name__ == "__main__":
59+
main(sys.argv)

0 commit comments

Comments
 (0)