本文整理汇总了Python中pybullet.getCameraImage方法的典型用法代码示例。如果您正苦于以下问题:Python pybullet.getCameraImage方法的具体用法?Python pybullet.getCameraImage怎么用?Python pybullet.getCameraImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybullet
的用法示例。
在下文中一共展示了pybullet.getCameraImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _render
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def _render(self, mode='human', close=False):
if mode != "rgb_array":
return np.array([])
base_pos,orn = self._p.getBasePositionAndOrientation(self._racecar.racecarUniqueId)
view_matrix = self._p.computeViewMatrixFromYawPitchRoll(
cameraTargetPosition=base_pos,
distance=self._cam_dist,
yaw=self._cam_yaw,
pitch=self._cam_pitch,
roll=0,
upAxisIndex=2)
proj_matrix = self._p.computeProjectionMatrixFOV(
fov=60, aspect=float(RENDER_WIDTH)/RENDER_HEIGHT,
nearVal=0.1, farVal=100.0)
(_, _, px, _, _) = self._p.getCameraImage(
width=RENDER_WIDTH, height=RENDER_HEIGHT, viewMatrix=view_matrix,
projectionMatrix=proj_matrix, renderer=pybullet.ER_BULLET_HARDWARE_OPENGL)
rgb_array = np.array(px)
rgb_array = rgb_array[:, :, :3]
return rgb_array
示例2: take_picture
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def take_picture(renderer, width=256, height=256, scale=0.001, conn_id=None):
view_matrix = p.computeViewMatrix(
[0, 0, -1], [0, 0, 0], [0, -1, 0], physicsClientId=conn_id
)
proj_matrix = p.computeProjectionMatrixFOV(
20, 1, 0.05, 2, physicsClientId=conn_id
)
w, h, rgba, depth, mask = p.getCameraImage(
width=width,
height=height,
projectionMatrix=proj_matrix,
viewMatrix=view_matrix,
renderer=renderer,
physicsClientId=conn_id,
)
return rgba
示例3: render
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def render(self):
if np.all(self._rendered_pos == self.camera_pos) and np.all(self._rendered_rot == self.camera_rot):
return self._rendered
target = self.camera_pos + np.dot(self.camera_rot, [0, 0, 1.0, 1.0])[0:3]
up = np.dot(self.camera_rot, [0, -1.0, 0, 1.0])[0:3]
vm = pb.computeViewMatrix(self.camera_pos, target, up)
i_arr = pb.getCameraImage(self.im_width, self.im_height, vm, self.pm,
shadow=0,
renderer=pb.ER_TINY_RENDERER)
# renderer=pb.ER_BULLET_HARDWARE_OPENGL)
# Record the position of the camera, and don't re-render if it hasn't moved.
self._rendered = i_arr
self._rendered_pos = self.camera_pos.copy()
self._rendered_rot = self.camera_rot.copy()
return i_arr
示例4: _render
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def _render(self, mode, close):
base_pos=[0,0,0]
if (hasattr(self,'robot')):
if (hasattr(self.robot,'body_xyz')):
base_pos = self.robot.body_xyz
view_matrix = p.computeViewMatrixFromYawPitchRoll(
cameraTargetPosition=base_pos,
distance=self._cam_dist,
yaw=self._cam_yaw,
pitch=self._cam_pitch,
roll=0,
upAxisIndex=2)
proj_matrix = p.computeProjectionMatrixFOV(
fov=60, aspect=float(self._render_width)/self._render_height,
nearVal=0.1, farVal=100.0)
(_, _, px, _, _) = p.getCameraImage(
width=self._render_width, height=self._render_height, viewMatrix=view_matrix,
projectionMatrix=proj_matrix,
renderer=p.ER_BULLET_HARDWARE_OPENGL
)
rgb_array = np.array(px).reshape((self._render_width, self._render_height, -1))
if close: return None
rgb_array = rgb_array[:, :, :3]
return rgb_array
示例5: render_physics
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def render_physics(self):
robot_pos, _ = p.getBasePositionAndOrientation(self.robot_tracking_id)
view_matrix = p.computeViewMatrixFromYawPitchRoll(
cameraTargetPosition=robot_pos,
distance=self.tracking_camera["distance"],
yaw=self.tracking_camera["yaw"],
pitch=self.tracking_camera["pitch"],
roll=0,
upAxisIndex=2)
proj_matrix = p.computeProjectionMatrixFOV(
fov=60, aspect=float(self._render_width)/self._render_height,
nearVal=0.1, farVal=100.0)
with Profiler("render physics: Get camera image"):
(_, _, px, _, _) = p.getCameraImage(
width=self._render_width, height=self._render_height, viewMatrix=view_matrix,
projectionMatrix=proj_matrix,
renderer=p.ER_TINY_RENDERER
)
rgb_array = np.array(px).reshape((self._render_width, self._render_height, -1))
rgb_array = rgb_array[:, :, :3]
return rgb_array
示例6: render_map
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def render_map(self):
base_pos=[0, 0, -3]
if (hasattr(self,'robot')):
if (hasattr(self.robot,'body_xyz')):
base_pos[0] = self.robot.body_xyz[0]
base_pos[1] = self.robot.body_xyz[1]
view_matrix = p.computeViewMatrixFromYawPitchRoll(
cameraTargetPosition=base_pos,
distance=35,
yaw=0,
pitch=-89,
roll=0,
upAxisIndex=2)
proj_matrix = p.computeProjectionMatrixFOV(
fov=60, aspect=float(self._render_width)/self._render_height,
nearVal=0.1, farVal=100.0)
(_, _, px, _, _) = p.getCameraImage(
width=self._render_width, height=self._render_height, viewMatrix=view_matrix,
projectionMatrix=proj_matrix,
renderer=p.ER_BULLET_HARDWARE_OPENGL
)
rgb_array = np.array(px).reshape((self._render_width, self._render_height, -1))
rgb_array = rgb_array[:, :, :3]
return rgb_array
示例7: _render
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def _render(self, mode, close):
base_pos=[0,0,0]
if (hasattr(self,'robot')):
if (hasattr(self.robot,'body_xyz')):
base_pos = self.robot.body_xyz
view_matrix = p.computeViewMatrixFromYawPitchRoll(
cameraTargetPosition=base_pos,
distance=self._cam_dist,
yaw=self._cam_yaw,
pitch=self._cam_pitch,
roll=0,
upAxisIndex=2)
proj_matrix = p.computeProjectionMatrixFOV(
fov=60, aspect=float(self._render_width)/self._render_height,
nearVal=0.1, farVal=100.0)
(_, _, px, _, _) = p.getCameraImage(
width=self._render_width, height=self._render_height, viewMatrix=view_matrix,
projectionMatrix=proj_matrix,
renderer=p.ER_BULLET_HARDWARE_OPENGL
)
rgb_array = np.array(px)
if close: return None
rgb_array = rgb_array[:, :, :3]
return rgb_array
示例8: render_physics
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def render_physics(self):
robot_pos, _ = p.getBasePositionAndOrientation(self.robot_tracking_id)
view_matrix = p.computeViewMatrixFromYawPitchRoll(
cameraTargetPosition=robot_pos,
distance=self.tracking_camera["distance"],
yaw=self.tracking_camera["yaw"],
pitch=self.tracking_camera["pitch"],
roll=0,
upAxisIndex=2)
proj_matrix = p.computeProjectionMatrixFOV(
fov=60, aspect=float(self._render_width)/self._render_height,
nearVal=0.1, farVal=100.0)
with Profiler("render physics: Get camera image"):
(_, _, px, _, _) = p.getCameraImage(
width=self._render_width, height=self._render_height, viewMatrix=view_matrix,
projectionMatrix=proj_matrix,
renderer=p.ER_TINY_RENDERER
)
rgb_array = np.array(px)
rgb_array = rgb_array[:, :, :3]
return rgb_array
示例9: render_map
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def render_map(self):
base_pos=[0, 0, -3]
if (hasattr(self,'robot')):
if (hasattr(self.robot,'body_xyz')):
base_pos[0] = self.robot.body_xyz[0]
base_pos[1] = self.robot.body_xyz[1]
view_matrix = p.computeViewMatrixFromYawPitchRoll(
cameraTargetPosition=base_pos,
distance=35,
yaw=0,
pitch=-89,
roll=0,
upAxisIndex=2)
proj_matrix = p.computeProjectionMatrixFOV(
fov=60, aspect=float(self._render_width)/self._render_height,
nearVal=0.1, farVal=100.0)
(_, _, px, _, _) = p.getCameraImage(
width=self._render_width, height=self._render_height, viewMatrix=view_matrix,
projectionMatrix=proj_matrix,
renderer=p.ER_BULLET_HARDWARE_OPENGL
)
rgb_array = np.array(px)
rgb_array = rgb_array[:, :, :3]
return rgb_array
示例10: _waitForCorrectImageFormat
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def _waitForCorrectImageFormat(self):
"""
INTERNAL METHOD, to be called after the launch of the exctraction
thread. Blocking method, that will return when the array retrieved from
the @getCameraImage is not None and corresponds to the current
resolution
"""
try:
assert self.module_process.isAlive()
while self.getFrame() is None:
continue
while True:
image = self.getFrame()
if image.shape[1] == self.resolution.width and\
image.shape[0] == self.resolution.height:
break
except AssertionError:
return
示例11: test
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def test(args):
p.connect(p.GUI)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
fileName = os.path.join("mjcf", args.mjcf)
print("fileName")
print(fileName)
p.loadMJCF(fileName)
while (1):
p.stepSimulation()
p.getCameraImage(320,240)
time.sleep(0.01)
示例12: getExtendedObservation
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def getExtendedObservation(self):
#camEyePos = [0.03,0.236,0.54]
#distance = 1.06
#pitch=-56
#yaw = 258
#roll=0
#upAxisIndex = 2
#camInfo = p.getDebugVisualizerCamera()
#print("width,height")
#print(camInfo[0])
#print(camInfo[1])
#print("viewMatrix")
#print(camInfo[2])
#print("projectionMatrix")
#print(camInfo[3])
#viewMat = camInfo[2]
#viewMat = p.computeViewMatrixFromYawPitchRoll(camEyePos,distance,yaw, pitch,roll,upAxisIndex)
viewMat = [-0.5120397806167603, 0.7171027660369873, -0.47284144163131714, 0.0, -0.8589617609977722, -0.42747554183006287, 0.28186774253845215, 0.0, 0.0, 0.5504802465438843, 0.8348482847213745, 0.0, 0.1925382763147354, -0.24935829639434814, -0.4401884973049164, 1.0]
#projMatrix = camInfo[3]#[0.7499999403953552, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0000200271606445, -1.0, 0.0, 0.0, -0.02000020071864128, 0.0]
projMatrix = [0.75, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0000200271606445, -1.0, 0.0, 0.0, -0.02000020071864128, 0.0]
img_arr = p.getCameraImage(width=self._width,height=self._height,viewMatrix=viewMat,projectionMatrix=projMatrix)
rgb=img_arr[2]
np_img_arr = np.reshape(rgb, (self._height, self._width, 4))
self._observation = np_img_arr
return self._observation
示例13: _get_observation
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def _get_observation(self):
"""Return the observation as an image.
"""
img_arr = p.getCameraImage(width=self._width,
height=self._height,
viewMatrix=self._view_matrix,
projectionMatrix=self._proj_matrix)
rgb = img_arr[2]
np_img_arr = np.reshape(rgb, (self._height, self._width, 4))
return np_img_arr[:, :, :3]
示例14: capture_image
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def capture_image(self):
width, height, im, depth, seg = p.getCameraImage(64, 64, list(
self.view_matrix), list(self.projection_matrix), renderer=p.ER_TINY_RENDERER)
self.depth = depth
im = np.array(im).reshape([height, width, -1])
return im[:, :, :3]
示例15: record_video_frame
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getCameraImage [as 别名]
def record_video_frame(self):
if self.record_video and self.gui:
frame = np.reshape(p.getCameraImage(width=self.width, height=self.height, renderer=p.ER_BULLET_HARDWARE_OPENGL, physicsClientId=self.id)[2], (self.height, self.width, 4))[:, :, :3]
# frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
# self.video_writer.write(frame)