def publ_multiple_signal_names(): print "Publish bsig signal names......." ecal.initialize(sys.argv, "Python Signal name publisher") BSIG_INFO_OBJ = Radar_pb2.BsigDataRequest() publisher_roi_obj = ecal.publisher(topic_name="BsigSignalNames") # sig_name = "SIM VFB ALL.DataProcCycle.ObjSyncEgoDynamic.Longitudinal.MotVar.Velocity" sig_name_lst = ['SIM VFB ALL.DataProcCycle.ObjSyncEgoDynamic.Longitudinal.MotVar.Velocity', 'MTS.Package.TimeStamp', 'SIM VFB ALL.DataProcCycle.ObjSyncEgoDynamic.Longitudinal.MotVar.Accel', 'SIM VFB ALL.DataProcCycle.ObjSyncEgoDynamic.Lateral.YawRate.YawRate', 'SIM VFB ALL.DataProcCycle.ObjSyncEgoDynamic.Lateral.SlipAngle.SideSlipAngle', 'SIM VFB ALL.DataProcCycle.EMPublicObjData.Objects[%].Kinematic.fDistX', 'SIM VFB ALL.DataProcCycle.EMPublicObjData.Objects[%].Kinematic.fDistY', 'SIM VFB ALL.DataProcCycle.EMPublicObjData.Objects[%].Kinematic.fVrelX', 'SIM VFB ALL.DataProcCycle.EMPublicObjData.Objects[%].Legacy.uiLifeTime', 'SIM VFB ALL.DataProcCycle.EMPublicObjData.Objects[%].Attributes.eDynamicProperty', 'SIM VFB ALL.AlgoSenCycle.gSI_OOI_LIST.SI_OOI_LIST[%].object_id', 'SIM VFB ALL.AlgoSenCycle.gSI_OOI_LIST.SI_OOI_LIST[%].long_displacement', 'SIM VFB ALL.AlgoSenCycle.gSI_OOI_LIST.SI_OOI_LIST[%].lat_displacement_to_curvature'] BSIG_INFO_OBJ.bsigPath = bsig_path BSIG_INFO_OBJ.objectIdCount = 100 # BSIG_INFO_OBJ.timestamp = 1465391170943194 BSIG_INFO_OBJ.timestamp = 8308331816 for sig_name in sig_name_lst: BSIG_INFO_OBJ.signalNames.append(sig_name) # while ecal.ok(): # print("BSIG_INFO_OBJ.SerializeToString() :: ", BSIG_INFO_OBJ.SerializeToString()) time.sleep(1) publisher_roi_obj.send(BSIG_INFO_OBJ.SerializeToString())
def __init__(self): # Initialize ecal service for H5 reader # Initialize the proto message object ecal.initialize(sys.argv, "H5 data publisher") self.initialize_subscr_topics() self.initialize_publsr_topics() self.define_subscr_callbacks()
def __init__(self, H5FileName): self.h5_file_name = H5FileName self.tmstamp_lst = [] # Initialize eCAL ecal.initialize(sys.argv, "Point cloud data publisher") global ALGO_READINESS ALGO_READINESS = False self.initialize_subscr_topics() self.initialize_publsr_topics() self.define_subscr_callbacks()
def __init__(self): # Subscribe to the eCAL message to get the bsig path and the # signal names # self.bsig_path = bsig_pth # ecal.initialize(sys.argv, "Python signal value publisher") # Subscribe to RadarSignalRequest topic self.bsig_subscr_obj = ecal.subscriber(topic_name="BsigSignalNames") self.bsig_pub_obj = ecal.publisher(topic_name="BsigSignalValues") self.bsig_tmstamp_lst = [] self.sig_name_lst = [] self.subscribe_ecal_msgs()
def publ_signal_names(): print("Publish tracking data......") ecal.initialize(sys.argv, "Tracker data") publisher_roi_obj = ecal.publisher(topic_name="SR_Request") label_req_obj = AlgoInterface_pb2.LabelRequest() # image_path = r'D:\Work\2018\code\Tensorflow_code\Tracker\DLBasedSmartAnnotation\data\BlurCar2\img\0001.jpg' image_path = r'D:\Work\2018\code\Tensorflow_code\Tracker\DLBasedSmartAnnotation\data\LT52\img\0001.jpeg' # read the image # img = cv2.imread(image_path, cv2.IMREAD_COLOR) img = cv2.imread(image_path, cv2.IMREAD_COLOR) img_encoded = cv2.imencode('.png', img)[1].tostring() # print("img_encoded ::", img) img_str = img_encoded # Read its respective coordinates gt_boxes_path = r'D:\Work\2018\code\Tensorflow_code\Tracker\DLBasedSmartAnnotation\data\BlurCar2\groundtruth_rect.txt' image_nmber_idx = 1 - 1 with open(gt_boxes_path, 'r') as f: lines = f.readlines() line = lines[image_nmber_idx] img_trackid_lst = [2] x, y, w, h = [int(x) for x in line.split()] # 227 207 122 99 # print("ordinate:", x, y, w, h) # (xmin, ymin, xmax, ymax) = (227, 207, 349, 306) # (xmin, ymin, xmax, ymax) = (227, 204, 349, 306) (xmin, ymin, xmax, ymax) = (622, 180, 660, 335) # xmin = 227 # ymin = 207 # xmax = 349 # ymax = 306 print("ordinate::", xmin, ymin, xmax, ymax) label_req_obj.NextImg.imageData = img_str for evy_img_trkid in img_trackid_lst: # Assign the trackid here attrib_typ_obj = label_req_obj.CurrentAttr.add() attrib_typ_obj.trackID = evy_img_trkid attrib_typ_obj.trackername = "ADNet" # Loop in to send across the coordinates roi_min_obj = attrib_typ_obj.ROI.add() roi_min_obj.X = xmin roi_min_obj.Y = ymin roi_max_obj = attrib_typ_obj.ROI.add() roi_max_obj.X = xmax roi_max_obj.Y = ymax time.sleep(1) publisher_roi_obj.send(label_req_obj.SerializeToString())
def subscribe_signl_names(): ecal.initialize(sys.argv, "Detector mask subscriber") subscribe_sig_names_obj = ecal.subscriber(topic_name="Pixel_Response") rdr_sig_response = AlgoInterface_pb2.LabelResponse() while ecal.ok(): ret, msg, time = subscribe_sig_names_obj.receive(500) print("---:: ", ret, msg, time, type(msg)) if msg is not None: rdr_sig_response.ParseFromString(msg) object_attibute_lst = rdr_sig_response.NextAttr # print("object_attibute :: ", object_attibute_lst) for evry_obj_attr in object_attibute_lst: track_id = evry_obj_attr.trackID # print("track_id ::> ", track_id) class_obj = evry_obj_attr.type.object_class # print("class_obj :: ", class_obj) x1 = evry_obj_attr.ROI[0].X y1 = evry_obj_attr.ROI[0].Y x2 = evry_obj_attr.ROI[1].X y2 = evry_obj_attr.ROI[1].Y x3 = evry_obj_attr.ROI[2].X y3 = evry_obj_attr.ROI[2].Y x4 = evry_obj_attr.ROI[3].X y4 = evry_obj_attr.ROI[3].Y print("ordinates :: ", x1, x2, x3, x4, y1, y2, y3, y4) mask = evry_obj_attr.mask with open('img.txt', 'w+') as fhandle: fhandle.write(str(mask)) nparr = np.fromstring(mask, np.uint8) print("nparr :: ", nparr) re_img_np_ary = cv2.imdecode(nparr, cv2.IMREAD_COLOR) img_shape = re_img_np_ary.shape print("shape::", img_shape) cv2.imwrite('color_img.jpg', re_img_np_ary) cv2.imshow('Color image', re_img_np_ary) cv2.waitKey(0) cv2.destroyAllWindows()
def publ_signal_names(): print "Publish bsig signal names......." ecal.initialize(sys.argv, "Python Signal name publisher") BSIG_INFO_OBJ = Radar_pb2.BsigDataRequest() publisher_roi_obj = ecal.publisher(topic_name="BsigSignalNames") sig_name_lst = ['MTS.Package.TimeStamp'] BSIG_INFO_OBJ.bsigPath = bsig_path BSIG_INFO_OBJ.objectIdCount = 40 BSIG_INFO_OBJ.timestamp = -1 for sig_name in sig_name_lst: BSIG_INFO_OBJ.signalNames.append(sig_name) # while ecal.ok(): # print("BSIG_INFO_OBJ.SerializeToString() :: ", BSIG_INFO_OBJ.SerializeToString()) time.sleep(1) publisher_roi_obj.send(BSIG_INFO_OBJ.SerializeToString())
def publ_signal_names(): print "Publish bsig signal names......." ecal.initialize(sys.argv, "Python Signal name publisher") BSIG_INFO_OBJ = Radar_pb2.BsigDataRequest() publisher_roi_obj = ecal.publisher(topic_name="BsigSignalNames") bsig_path = r"D:\Work\2018\code\LT5G\OLT\Radar_labelling_bsig\bsig_readers\Continuous_2014.05.15_at_08.48.40.bsig" # bsig_path = r"D:\Work\2018\code\LT5G\OLT\Radar_labelling_bsig\bsig_readers\20160608_1306_{4556C7A6-7F27-4A91-923E-4392C9785675}.bsig" # sig_name = "SIM VFB ALL.DataProcCycle.ObjSyncEgoDynamic.Longitudinal.MotVar.Velocity" sig_name_lst = [ 'SIM VFB ALL.DataProcCycle.ObjSyncEgoDynamic.Longitudinal.MotVar.Velocity', 'MTS.Package.TimeStamp', 'SIM VFB ALL.DataProcCycle.ObjSyncEgoDynamic.Longitudinal.MotVar.Accel', 'SIM VFB ALL.DataProcCycle.ObjSyncEgoDynamic.Lateral.YawRate.YawRate', 'SIM VFB ALL.DataProcCycle.ObjSyncEgoDynamic.Lateral.SlipAngle.SideSlipAngle', 'SIM VFB ALL.DataProcCycle.EMPublicObjData.Objects[%].Kinematic.fDistX', 'SIM VFB ALL.DataProcCycle.EMPublicObjData.Objects[%].Kinematic.fDistY', 'SIM VFB ALL.DataProcCycle.EMPublicObjData.Objects[%].Kinematic.fVrelX', 'SIM VFB ALL.DataProcCycle.EMPublicObjData.Objects[%].Legacy.uiLifeTime', 'SIM VFB ALL.DataProcCycle.EMPublicObjData.Objects[%].Attributes.eDynamicProperty', 'SIM VFB ALL.AlgoSenCycle.gSI_OOI_LIST.SI_OOI_LIST[%].object_id', 'SIM VFB ALL.AlgoSenCycle.gSI_OOI_LIST.SI_OOI_LIST[%].long_displacement', 'SIM VFB ALL.AlgoSenCycle.gSI_OOI_LIST.SI_OOI_LIST[%].lat_displacement_to_curvature' ] # sig_name_lst = ['MTS.Package.TimeStamp' # ] BSIG_INFO_OBJ.bsigPath = bsig_path BSIG_INFO_OBJ.objectIdCount = 40 for sig_name in sig_name_lst: BSIG_INFO_OBJ.signalNames.append(sig_name) # while ecal.ok(): # print("BSIG_INFO_OBJ.SerializeToString() :: ", BSIG_INFO_OBJ.SerializeToString()) time.sleep(1) publisher_roi_obj.send(BSIG_INFO_OBJ.SerializeToString())
def publ_coord_multiple_obj(): print("Publish tracking data......") ecal.initialize(sys.argv, "Tracker data") publisher_roi_obj = ecal.publisher(topic_name="SR_Request") label_req_obj = algointerface_pb2.LabelRequest() image_path = r'D:\Work\2018\code\LT5G\ticket_folders\Images\MFC4xxLongImageRight_7674957039.jpeg' img = cv2.imread(image_path, cv2.IMREAD_COLOR) img_encoded = cv2.imencode('.png', img)[1].tostring() # print("img_encoded ::", img) img_str = img_encoded img_trackid_lst = [2, 3] coordinate_tpl_lst = [(622, 180, 660, 335), (227, 204, 349, 306)] # (xmin, ymin, xmax, ymax) = (622, 180, 660, 335) # print("ordinate::", xmin, ymin, xmax, ymax) chnl_obj = label_req_obj.channelobject.add() chnl_obj.channelName = 'LongImage' tmstamp_obj = chnl_obj.timestampobject.add() tmstamp_obj.timestamp = 54376457 tmstamp_obj.NextImg.imageData = img_str for idx, evy_img_trkid in enumerate(img_trackid_lst): attrib_typ_obj = tmstamp_obj.CurrentAttr.add() attrib_typ_obj.trackID = evy_img_trkid attrib_typ_obj.trackername = "Re3" attrib_typ_obj.hasUserCorrected = 1 # Loop in to send across the coordinates roi_min_obj = attrib_typ_obj.ROI.add() roi_min_obj.X = coordinate_tpl_lst[idx][0] roi_min_obj.Y = coordinate_tpl_lst[idx][1] roi_max_obj = attrib_typ_obj.ROI.add() roi_max_obj.X = coordinate_tpl_lst[idx][2] roi_max_obj.Y = coordinate_tpl_lst[idx][3] time.sleep(1) publisher_roi_obj.send(label_req_obj.SerializeToString())
def __init__(self): self.tracker = re3_tracker.Re3Tracker() self.trkid_lst = [] # Initialize eCAL ecal.initialize(sys.argv, "object tracking") # Read the JSON files with open(topics_json_path) as data_file: self.json_data = json.load(data_file) # Topic names self.tracker_request = self.json_data['image_request'] self.tracker_response = self.json_data['image_response'] print("Tracker initialization done!!") # Define the callbacks for publisher subscriber self.initialize_subscr_topics() self.initialize_publsr_topics() # The callbacks will redirect to the tracker function and publish predicted ROI self.define_subscr_callbacks()
import ecal import AlgoInterface_pb2 import imageservice_pb2 import sys ecal.initialize(sys.argv, "HFL data requestor") hfl_publ_obj = ecal.publisher("Request_Image") import time time.sleep(2) hfl_req_proto_obj = imageservice_pb2.ImageRequest() def request_hfl_data(): # while ecal.ok(): # hfl_req_proto_obj.required_timestamp = 1504816617728550 hfl_req_proto_obj.image_index = 8 #1504816617788522 # hfl_req_proto_obj.hfl_file_name = "D:\\Work\\2018\\code\\LT5G\\HDF5_reader\\2017.09.07_at_20.37.57_camera-mi_1449.h5" hfl_publ_obj.send(hfl_req_proto_obj.SerializeToString()) ecal.finalize() request_hfl_data()
import imageservice_pb2 import json import cv2 if getattr(sys, 'frozen', False): os.chdir(sys._MEIPASS) with open('topics.json') as data_file: json_data = json.load(data_file) # print(json_data) request = str(json_data['request']) response = str(json_data['response']) h5_filename = str(json_data['h5_filename']) ecal.initialize(sys.argv, "HFL data publisher") hfl_subscr_obj = ecal.subscriber(request) hfl_publs_obj = ecal.publisher(topic_name=response) hfl_req_proto_obj = imageservice_pb2.ImageRequest() hfl_resp_proto_obj = imageservice_pb2.HFLResponse() class H5ReaderSequence(object): def __init__(self, fname): self.reset(fname) self.lastLoadFilename = "" def reset(self, fname): if not os.path.isfile(fname): print("Error - H5 file not available: %s!" % fname)
import ecal import common_pb2 import sys import time ecal.initialize(sys.argv, "Point Cloud data requestor") tmstamp_publ_obj = ecal.publisher("PointCloud_Device_Request") pcl_publ_obj = ecal.publisher("PointCloud_Data_Request") pcl_finalize_obj = ecal.publisher("Finalize") time.sleep(2) def req_timestamp(): dvc_data_proto_obj = common_pb2.DevicesDataRequest() dvc_data_proto_obj.requiredDevicesData = True payload = dvc_data_proto_obj.SerializeToString() # print "payload :: ", payload tmstamp_publ_obj.send(payload) ecal.finalize() def req_pcl_points(): pcl_data_proto_obj = common_pb2.DataRequest() pcl_data_proto_obj.requiredTimestamp = 1521225338975243 #1521225351544589 pcl_data_proto_obj.requestDeviceName = "HFL" pcl_data_proto_obj.requestChannelName = "Valodyne" pcl_data_proto_obj.uniqueId = 1 payload = pcl_data_proto_obj.SerializeToString() # print "payload :: ", payload pcl_publ_obj.send(payload)
def __init__(self, tracker_request, tracker_response): # Topic names self.tracker_request = tracker_request self.tracker_response = tracker_response # Tracker initializers './conf/repo.yaml' ADNetConf.get(conf_yaml_path) self.tensor_input = tf.placeholder(tf.float32, shape=(None, 112, 112, 3), name='patch') self.tensor_action_history = tf.placeholder(tf.float32, shape=(None, 1, 1, 110), name='action_history') self.tensor_lb_action = tf.placeholder(tf.int32, shape=(None, ), name='lb_action') self.tensor_lb_class = tf.placeholder(tf.int32, shape=(None, ), name='lb_class') self.tensor_is_training = tf.placeholder(tf.bool, name='is_training') self.learning_rate_placeholder = tf.placeholder(tf.float32, [], name='learning_rate') self.persistent_sess = tf.Session(config=tf.ConfigProto( inter_op_parallelism_threads=1, intra_op_parallelism_threads=1)) self.adnet = ADNetwork(self.learning_rate_placeholder) self.adnet.create_network(self.tensor_input, self.tensor_lb_action, self.tensor_lb_class, self.tensor_action_history, self.tensor_is_training) if 'ADNET_MODEL_PATH' in os.environ.keys(): self.adnet.read_original_weights(self.persistent_sess, os.environ['ADNET_MODEL_PATH']) else: self.adnet.read_original_weights(self.persistent_sess) # print("self.action_histories >>", ADNetConf.get()) self.action_histories = np.array([0] * ADNetConf.get()['action_history'], dtype=np.int8) self.action_histories_old = np.array([0] * ADNetConf.get()['action_history'], dtype=np.int8) self.histories = [] self.iteration = 0 self.imgwh = None self.callback_redetection = self.redetection_by_sampling print("Tracker initialization Done!!") # Initialize eCAL ecal.initialize(sys.argv, "object tracking") # Read the JSON files with open(topics_json_path) as data_file: self.json_data = json.load(data_file) # Define the callbacks for publisher subscriber self.initialize_subscr_topics() self.initialize_publsr_topics() # The callbacks will redirect to the tracker function and publish predicted ROI self.define_subscr_callbacks()
def publ_coord_single_obj(): print("Publish tracking data......") ecal.initialize(sys.argv, "Tracker data") publisher_roi_obj = ecal.publisher(topic_name="SR_Request") label_req_obj = algointerface_pb2.LabelRequest() image_path = r'D:\Work\2018\code\LT5G\ticket_folders\Images\MFC4xxLongImageRight_7674957039.jpeg' # image_path = r'0001.jpeg' # read the image # img = cv2.imread(image_path, cv2.IMREAD_COLOR) img = cv2.imread(image_path, cv2.IMREAD_COLOR) img_encoded = cv2.imencode('.png', img)[1].tostring() # print("img_encoded ::", img) img_str = img_encoded # Read its respective coordinates # gt_boxes_path = r'D:\Work\2018\code\Tensorflow_code\Tracker\DLBasedSmartAnnotation\data\BlurCar2\groundtruth_rect.txt' image_nmber_idx = 1 - 1 # with open(gt_boxes_path, 'r') as f: # lines = f.readlines() # line = lines[image_nmber_idx] img_trackid_lst = [2] # x, y, w, h = [int(x) for x in line.split()] # 227 207 122 99 # print("ordinate:", x, y, w, h) # (xmin, ymin, xmax, ymax) = (227, 207, 349, 306) # (xmin, ymin, xmax, ymax) = (227, 204, 349, 306) (xmin, ymin, xmax, ymax) = (622, 180, 660, 335) # xmin = 227 # ymin = 207 # xmax = 349 # ymax = 306 print("ordinate::", xmin, ymin, xmax, ymax) # label_req_obj.NextImg.imageData = img_str # for evy_img_trkid in img_trackid_lst: # # Assign the trackid here # attrib_typ_obj = label_req_obj.CurrentAttr.add() # attrib_typ_obj.trackID = evy_img_trkid # attrib_typ_obj.trackername = "ADNet" # # Loop in to send across the coordinates # roi_min_obj = attrib_typ_obj.ROI.add() # roi_min_obj.X = xmin # roi_min_obj.Y = ymin # roi_max_obj = attrib_typ_obj.ROI.add() # roi_max_obj.X = xmax # roi_max_obj.Y = ymax chnl_obj = label_req_obj.channelobject.add() chnl_obj.channelName = 'LongImage' tmstamp_obj = chnl_obj.timestampobject.add() tmstamp_obj.timestamp = 54376457 tmstamp_obj.NextImg.imageData = img_str for evy_img_trkid in img_trackid_lst: attrib_typ_obj = tmstamp_obj.CurrentAttr.add() attrib_typ_obj.trackID = evy_img_trkid attrib_typ_obj.trackername = "Re3" attrib_typ_obj.hasUserCorrected = 1 # Loop in to send across the coordinates roi_min_obj = attrib_typ_obj.ROI.add() roi_min_obj.X = xmin roi_min_obj.Y = ymin roi_max_obj = attrib_typ_obj.ROI.add() roi_max_obj.X = xmax roi_max_obj.Y = ymax time.sleep(1) publisher_roi_obj.send(label_req_obj.SerializeToString())
# if getattr(sys, 'frozen', False): # os.chdir(sys.executable) FROZEN_MODEL = "mask_rcnn_coco.h5" TOPICS_JSON = 'topics.json' with open(TOPICS_JSON) as data_file: json_data = json.load(data_file) # print(json_data) request = str(json_data['image_request']) response = str(json_data['image_response']) vis_flag = True if str(json_data['visualization']) == "True" else False full_eff_flag = True if str(json_data['full_efficiency']) == "True" else False ecal.initialize(sys.argv, "Mask RCNN MS COCO detector") ld_req_obj = imageservice_pb2.ImageResponse() subscriber_obj = ecal.subscriber(topic_name=request) lbl_response_obj = AlgoInterface_pb2.LabelResponse() publisher_roi_obj = ecal.publisher(topic_name=response) class InferenceConfig(coco.CocoConfig): # Set batch size to 1 since we'll be running inference on # one image at a time. Batch size = GPU_COUNT * IMAGES_PER_GPU GPU_COUNT = 1 IMAGES_PER_GPU = 1 if not full_eff_flag: IMAGE_MIN_DIM = 512 IMAGE_MAX_DIM = 512