Esempio n. 1
0
 def __init__(self, calib_file=''):
     self.publisher = rospy.Publisher(IMAGE_TOPIC, Image, queue_size=1)
     rospy.init_node(NODE_NAME)
     width = rospy.get_param('~width', 640)
     height = rospy.get_param('~height', 480)
     rospy.logwarn(width)
     self.calib_file = calib_file
     self.camera = Camera(width=width,height=height)
Esempio n. 2
0
 def test_init_start_stop(self):
     """Test camera's thread init/start/stop methods."""
     camera = Camera()
     camera.start()
     time.sleep(1)
     image = bgr8_to_jpeg(camera.value)
     camera.stop()
     # Check if image changed after stopping
     assert image == bgr8_to_jpeg(camera.value)
     
         
Esempio n. 3
0
mean = torch.Tensor([0.485, 0.456, 0.406]).cuda().half()
std = torch.Tensor([0.229, 0.224, 0.225]).cuda().half()

def preprocess(image):
    image = PIL.Image.fromarray(image)
    image = transforms.functional.to_tensor(image).to(device).half()
    image.sub_(mean[:, None, None]).div_(std[:, None, None])
    return image[None, ...]

from IPython.display import display
import ipywidgets
import traitlets
from jetbot import Camera, bgr8_to_jpeg

camera = Camera()

image_widget = ipywidgets.Image()

traitlets.dlink((camera, 'value'), (image_widget, 'value'), transform=bgr8_to_jpeg)

display(image_widget)

from jetbot import Robot
robot = Robot()

speed_gain_slider = ipywidgets.FloatSlider(min=0.0, max=1.0, step=0.01, description='speed gain')
steering_gain_slider = ipywidgets.FloatSlider(min=0.0, max=1.0, step=0.01, value=0.2, description='steering gain')
steering_dgain_slider = ipywidgets.FloatSlider(min=0.0, max=0.5, step=0.001, value=0.0, description='steering kd')
steering_bias_slider = ipywidgets.FloatSlider(min=-0.3, max=0.3, step=0.01, value=0.0, description='steering bias')
Esempio n. 4
0
 def __init__(self, camera_width, camera_height):
     self.camera = Camera(width=camera_width, height=camera_height)
     self.image = None