def handle_docs_video(bot: Bot, update: Update): try: chat_id = update.message.chat.id file_info = bot.get_file(update.message.video.file_id) downloaded_file = file_info.download("in.mp4") #im = cv2.imread("") #height, width, channels = im.shape #im = cv2.resize(im, (640, 480)) #cv2.imwrite("test.png",im) bot.send_message(chat_id=chat_id, text="Создаю карту глубин...") video.video("in.mp4") video.save() #im = cv2.imread("depth.png") #im = cv2.resize(im, (width,height)) #cv2.imwrite("depth.png",im) ''' if height>width: im = cv2.imread("depth.png") im = cv2.resize(im, (240, 320)) cv2.imwrite("depth.png",im) ''' bot.send_message(chat_id=chat_id, text="Карта глубин готова.") bot.send_video(chat_id=chat_id, video=open('movie.mp4', 'rb')) #bot.send_message(chat_id= chat_id, text = "Создаю 3d модель") #make3d.start("depth.png") #bot.send_document(chat_id=chat_id, document=open('test_3d.stl', 'rb')) except Exception as e: bot.send_message(chat_id=chat_id, text=e)
plot_particles(X, Y, 'coordinates_end.png') # plot the partdist list # pylab.clf() # pylab.title('Particle Count for X > 0.0 and N < 10000') # pylab.xlabel('Number of particles where X > 0.0') # pylab.ylabel('Count') # pylab.hist(particle_dist, bins=range(0, n_particles), align='left') # pylab.xlim( (0, n_particles) ) # pylab.savefig('partdist.png') # pylab.savefig('partdist.eps') # plot the partdisteq list # pylab.clf() # pylab.title('Particle Count for X > 0.0 and N > 10000') # pylab.xlabel('Number of particles where X > 0.0') # pylab.ylabel('Count') # pylab.hist(particle_dist_eq, bins=range(0, n_particles), rwidth=1, align='left') # pylab.xlim( (0, n_particles) ) # pylab.savefig('partdisteq.png') # pylab.savefig('partdisteq.eps') video.save(1.0, 'hard_sphere')
# for every step for i in range(n_particles): # if the particle is exiting the box in the x-direction, change the # velocity if abs(pos_x[i] + vel_x[i] * dt) > 1.0: vel_x[i] = -vel_x[i] if abs(pos_y[i] + vel_y[i] * dt) > 1.0: vel_y[i] = -vel_y[i] # make a step in time dt pos_x[i] = pos_x[i] + vel_x[i] * dt pos_y[i] = pos_y[i] + vel_y[i] * dt # save a 'frame' for the video every 10 step if n % 10 == 0: video.add_frame(pos_x, y_pos) # Plot the x- and y- coordinates pylab.clf() # clear figure pylab.plot(pos_x, pos_y, "ro") pylab.axis((-1, 1, -1, 1)) pylab.savefig("coordinates_end.eps") pylab.savefig("coordinates_end.png") # Save video pylab.clf() video.save(1.0, "non_interacting_particles")