Skip to content

Instantly share code, notes, and snippets.

View zxf8665905's full-sized avatar

XueFeng Zeng zxf8665905

  • Horizon Robotics Inc
  • china
View GitHub Profile
@zxf8665905
zxf8665905 / image2video.py
Created May 11, 2018 04:11
image to video
video_name = 'out.mp4'
frame = cv2.imread(images[0])
height, width, layers = frame.shape
fourcc = cv2.VideoWriter_fourcc(*'H264’) # may try x264
video = cv2.VideoWriter(video_name, fourcc, 6, (width,height))
for image in images:
video.write(cv2.imread(image))
@zxf8665905
zxf8665905 / heat_map_rgb.py
Created May 11, 2018 04:10
get heatmap rgb
def heat_map_rgb(minimum, maximum, value):
minimum, maximum = float(minimum), float(maximum)
ratio = 2 * (value-minimum) / (maximum - minimum)
b = int(max(0, 255*(1 - ratio)))
r = int(max(0, 255*(ratio - 1)))
g = 255 - b - r
return (r, g, b)
## https://gist.github.com/pierriko/fd49abfa2fb3561f9c89
## https://github.com/omgteam/Didi-competition-solution
# attach process: https://www.jetbrains.com/help/pycharm/2016.3/attaching-to-local-process.html
import sys
##sys.path.insert(0,'/opt/ros/kinetic/lib/python2.7/dist-packages')
##sys.path.insert(0,'/usr/lib/python2.7/dist-packages') ## rospkg
import os
@zxf8665905
zxf8665905 / rosbag_image_export.py
Created September 5, 2017 14:26
Export image from rosbag
import rospy
import rosbag
import numpy as np
import cv2
import message_filters
import sys, os
from sensor_msgs import point_cloud2
import glob
from cv_bridge import CvBridge, CvBridgeError
@zxf8665905
zxf8665905 / rosbag_split.py
Created September 5, 2017 14:17
split large ros bag to small bag
#!/usr/bin/env python
import rosbag
import os
from shutil import copyfile
import glob
bags_path = glob.glob('/home/aaa/dataset/*.bag')
for bag_file in bags_path:
bag = rosbag.Bag(bag_file)