Exemplo n.º 1
0
def test3():

	terrain = "terrains/griffith.stl"
	fig = plt.figure(figsize=(16, 8))
	specs = {"xmax":30, "ymax":20, "focalx":15, "focaly":10, "focalz":2} # units of pixel except for focalz ....

	########## First figure axis ##########
	ax1 = fig.add_subplot(1, 2, 1, projection='3d')
	your_mesh = mesh.Mesh.from_file(terrain)
	ax1.add_collection3d(mplot3d.art3d.Poly3DCollection(your_mesh.vectors))
	scale = your_mesh.points.flatten(-1)
	ax1.auto_scale_xyz(scale, scale, scale)

	orientation1=(0,0,0)
	snap1 = camera.snap(20, 20, 20, *orientation1, **specs)
	orientation2=(0,0,0)
	snap2 = camera.snap(30, 20, 20, *orientation2, **specs)
	plot_camera(ax1, snap1, True)
	plot_camera(ax1, snap2, True)
	set_bounds(ax1)

	########## Second figure axis ##########
	ax2 = fig.add_subplot(1, 2, 2, projection='3d')
	set_axes_equal(ax1,ax2)
	proj1 = projection.pointcloud(snap1)
	pointcloud1 = proj1.project_to_mesh(terrain, convert=True)
	proj2 = projection.pointcloud(snap2)
	pointcloud2 = proj2.project_to_mesh(terrain, convert=True)
	ax2.scatter(*pointcloud1)
	ax2.scatter(*pointcloud2)

	plt.show()
Exemplo n.º 2
0
def test2():
	# fig = plt.figure(figsize=plt.figaspect(0.5))
	fig = plt.figure(figsize=(16, 8))
	specs = {"xmax":30, "ymax":20, "focalx":15, "focaly":10, "focalz":2} # units of pixel except for focalz ....

	# # First figure axis
	ax1 = fig.add_subplot(1, 2, 1, projection='3d')
	ground = world.ground(100,100)
	plot_world(ax1, ground)
	# cube = world.cube(0,0,10)
	# plot_surfs(ax1, *cube)

	orientation2=(0,30,0)
	snap1 = camera.snap(0, 0, 30, *orientation2, **specs)
	plot_camera(ax1, snap1, True)
	set_bounds(ax1)


	# # Second figure axis 
	ax2 = fig.add_subplot(1, 2, 2, projection='3d')
	set_axes_equal(ax1,ax2)
	pointcloud = projection.pointcloud(snap1, ground)
	ground_cloud = projection.points_to_pointcloud(pointcloud.project_to_ground())
	ax2.scatter(*ground_cloud)


	plt.show()
Exemplo n.º 3
0
def test1():
	# fig = plt.figure(figsize=plt.figaspect(0.5))
	fig = plt.figure(figsize=(16, 8))
	specs = {"xmax":30, "ymax":20, "focalx":15, "focaly":10, "focalz":2} # units of pixel except for focalz ....

	# First figure axis
	ax1 = fig.add_subplot(1, 2, 1, projection='3d')
	ground = world.ground(100,100)
	surf1 = plot_world(ax1, ground)
	
	# plane1 = world.xz_plane(20,20,0,-10,0) 
	# plane2 = world.xz_plane(20,20,0,10, 0)
	# plane3 = world.yz_plane(20,20,-10,0,0)
	# plane4 = world.yz_plane(20,20,10,0,0)
	# plane5 = world.xy_plane(20,20,0,0,20)
	# plot_surfs(ax1, plane1, plane2, plane3, plane4, plane5)
	cube = world.cube(0,0,10)
	plot_surfs(ax1, *cube)
	box = world.box((-50,-50,20),(-50,50,20),(-40,50,20),(-40,-50,20))
	plot_surfs(ax1, *box)


	orientation2=(0,30,0)
	snap1 = camera.snap(0, 0, 30, *orientation2, **specs)
	plot_camera(ax1, snap1, True)
	set_bounds(ax1)
Exemplo n.º 4
0
 def add_camera(self, x, y, z, rotx, roty, rotz, time):
     orientation = (rotx, roty, rotz)
     snap = camera.snap(x, y, z, *orientation, **self.specs)
     self.cameras.append(snap)
     self.times.append(time)
     proj = projection.pointcloud(snap)
     self.projections.append(proj)
Exemplo n.º 5
0
	def add_camera(self, x, y, z, rotx, roty, rotz):
		orientation = (rotx,roty,rotz)
		snap = camera.snap(x, y, z, *orientation, **self.specs)
		self.cameras.append(snap)
		proj = projection.pointcloud(snap)
		self.projections.append(proj)
		if self.filename:
			pointcloud = proj.project_to_mesh(self.terrain, camera_pov=False, convert=False)
			pointsmessage = exporter.xyz_array_to_pointcloud2(pointcloud)
			exporter.make_bag_file(self.filename, pointsmessage)
Exemplo n.º 6
0
def render():
    fig = plt.figure(figsize=plt.figaspect(0.5))

    # First Camera
    # ax1 = fig.gca(projection='3d')
    ax1 = fig.add_subplot(1, 2, 1, projection='3d')
    surf1 = world.surface(300, 300)
    snap1 = camera.snap(100, 100, 50, (0, 30, 0), 20, 30, 30)
    world1 = plot_world(surf1, ax1)
    plot_camera(snap1, ax1)
    set_axes_equal(ax1)
    fig.colorbar(world1, shrink=0.5, aspect=5)

    # Visualize point cloud in different figure axis
    ax2 = fig.add_subplot(1, 2, 2, projection='3d')
    surf2 = world.surface(300, 300)
    snap2 = camera.snap(100, 100, 50, (0, 30, 0), 20, 30, 30)
    world2 = plot_world(surf2, ax2)
    plot_camera(snap2, ax2, plotrays=False)
    set_axes_equal(ax2)
    fig.colorbar(world2, shrink=0.5, aspect=5)

    plt.show()
Exemplo n.º 7
0
def render():
    # fig = plt.figure(figsize=plt.figaspect(0.5))
    fig = plt.figure(figsize=(16, 8))
    specs = {
        "xmax": 30,
        "ymax": 20,
        "focalx": 15,
        "focaly": 10,
        "focalz": 2
    }  # units of pixel except for focalz ....

    ########## First figure axis ##########
    ax1 = fig.add_subplot(1, 2, 1, projection='3d')
    ground = world.ground(100, 100)
    plot_world(ax1, ground)
    # cube = world.cube(0,0,10)
    # plot_surfs(ax1, *cube)

    box = world.box((50, -50, 20), (50, 50, 20), (30, 50, 20), (30, -50, 20))
    plot_surfs(ax1, *box)

    orientation2 = (0, -20, 0)
    snap1 = camera.snap(20, 0, 50, *orientation2, **specs)
    plot_camera(ax1, snap1, True)
    set_bounds(ax1)

    ########## Second figure axis ##########
    ax2 = fig.add_subplot(1, 2, 2, projection='3d')
    set_axes_equal(ax1, ax2)

    # pointcloud = projection.pointcloud(snap1)
    # ground_cloud = projection.points_to_pointcloud(pointcloud.project_to_ground())
    # ax2.scatter(*ground_cloud)

    # pointcloud = projection.pointcloud(snap1)
    # box_cloud = projection.points_to_pointcloud(pointcloud.penetrate_plane(*box, camera_pov=False))
    # ax2.scatter(*box_cloud)

    proj2 = projection.pointcloud(snap1)
    pointcloud2 = proj2.project_to_plane(*box, ground, camera_pov=False)
    box_cloud = projection.points_to_pointcloud(pointcloud2)
    ax2.scatter(*box_cloud)

    plt.show()
Exemplo n.º 8
0
    database=cred['connection']['database'],
    #port=cred['connection']['port']
)

mycursor = mydb.cursor()


def writeImagePath(image_path, timeStr):
    sql = "INSERT INTO images (path,datetime) VALUES (%s,%s)"
    val = (image_path, timeStr)
    mycursor.execute(sql, val)
    mydb.commit()


while True:
    now = time.localtime()
    timeStr = str(now[1]) + '/' + str(now[2]) + '/' + str(
        now[0]) + ' - ' + str(now[3]) + ':' + str(now[4])
    timestamp = str(now[0]) + str(now[1]).zfill(2) + str(
        now[2]).zfill(2) + str(now[3]).zfill(2) + str(now[4]).zfill(2)
    datestamp = str(now[0]) + '-' + str(now[1]).zfill(2) + '-' + str(
        now[2]).zfill(2)
    dateTime = str(now[0]) + '-' + str(now[1]).zfill(2) + '-' + str(
        now[2]).zfill(2) + ' ' + str(now[3]).zfill(2) + ':' + str(
            now[4]).zfill(2) + ':' + str(now[5]).zfill(2)
    image_path = os.path.join("..", "dash", "static", "dash", "images",
                              datestamp, timestamp + '.jpg')
    camera.snap(image_path, timeStr)
    writeImagePath(image_path, dateTime)
    time.sleep(300)
Exemplo n.º 9
0
		plot_camera(ax1, snap, True)
	set_bounds(ax1)

	########## Second figure axis ##########
	ax2 = fig.add_subplot(1, 2, 2, projection='3d')
	set_axes_equal(ax1,ax2)

	for pointcloud in pointclouds:
		ax2.scatter(*pointcloud)
	
	plt.show()



if __name__== "__main__":
	terrain = "terrains/griffith.stl"
	specs = {"xmax":30, "ymax":20, "focalx":15, "focaly":10, "focalz":2} # units of pixel except for focalz ....

	orientation1=(0,0,0)
	snap1 = camera.snap(20, 20, 20, *orientation1, **specs)
	orientation2=(0,0,0)
	snap2 = camera.snap(30, 20, 20, *orientation2, **specs)

	proj1 = projection.pointcloud(snap1)
	pointcloud1 = proj1.project_to_mesh(terrain, convert=True)
	proj2 = projection.pointcloud(snap2)
	pointcloud2 = proj2.project_to_mesh(terrain, convert=True)

	render(terrain, [snap1, snap2], [pointcloud1, pointcloud2])

Exemplo n.º 10
0
#!/usr/bin/env python
import camera
import sys

if len(sys.argv) > 1:
    camera.snap(str(sys.argv[1]))
else:
    camera.snap('')