def imgPublisher(): image = sqlconnect() rospy.init_node('ShelfPub', anonymous=True) pubshelf = rospy.Publisher('shelfori', Image, queue_size=10) pub = rospy.Publisher('shelfimg', Image, queue_size=10) pub2 = rospy.Publisher('shelfimg2', Image, queue_size=10) pub3 = rospy.Publisher('shelfimg3', Image, queue_size=10) #numpub = rospy.Publisher('shelfnum',String, queue_size=10) DBpub = rospy.Publisher('shelfDB', DBinfo, queue_size=10) bridge = CvBridge() DBdata = DBinfo() idnum = 0 for i in range(20): DBdata.Frame[i] = Info[i][0] DBdata.id[i] = Info[i][1] DBdata.Xmin[i] = Info[i][2] DBdata.Ymin[i] = Info[i][3] DBdata.Width[i] = Info[i][4] DBdata.Height[i] = Info[i][5] if (Info[i][1] == idnum): imagenum[idnum] = i idnum = idnum + 1 shelfOri = bridge.cv2_to_imgmsg(shelfCut, encoding="bgr8") print(imagenum[0]) msg = bridge.cv2_to_imgmsg(image[imagenum[0]], encoding="bgr8") print(imagenum[1]) msg2 = bridge.cv2_to_imgmsg(image[imagenum[1]], encoding="bgr8") print(type(image[4])) msg3 = bridge.cv2_to_imgmsg(image[imagenum[2]], encoding="bgr8") rate = rospy.Rate(0.5) #print(str(Info[0][0])) print("Pulish") for k in range(2): #numpub.publish(str2) DBpub.publish(DBdata) rate.sleep() for i in range(3): pubshelf.publish(shelfOri) pub.publish(msg) pub2.publish(msg2) pub3.publish(msg3) rate.sleep() print("finish") print('Wait...')
def imgPublisher(): image = sqlconnect() rospy.init_node('ShelfPub', anonymous=True) pub = rospy.Publisher('shelfimg', Image, queue_size=10) pub2 = rospy.Publisher('shelfimg2', Image, queue_size=10) numpub = rospy.Publisher('shelfnum', String, queue_size=10) DBpub = rospy.Publisher('shelfDB', DBinfo, queue_size=10) bridge = CvBridge() msg = bridge.cv2_to_imgmsg(image[0], encoding="bgr8") msg2 = bridge.cv2_to_imgmsg(image[2], encoding="bgr8") str2 = str(Info[0][0]) DBdata = DBinfo() for i in range(20): DBdata.Frame[i] = Info[i][0] DBdata.id[i] = Info[i][1] DBdata.Xmin[i] = Info[i][2] DBdata.Ymin[i] = Info[i][3] DBdata.Width[i] = Info[i][4] DBdata.Height[i] = Info[i][5] rate = rospy.Rate(0.5) #print(str(Info[0][0])) print("Pulish") for k in range(2): #numpub.publish(str2) DBpub.publish(DBdata) rate.sleep() for i in range(3): pub.publish(msg) pub2.publish(msg2) rate.sleep() print("finish") print('Wait...')
def imgPublisher(): # sqlconnect関数に入り物体情報を取得 global cntone image = sqlconnect() # 初期化 : ソフトウェア名は「ShelfPub」 rospy.init_node('ShelfPub', anonymous=True) # nodeの宣言 : publisherのインスタンスを作成 # 「shelfori」というTopicにImage型のメッセージを送るPublisherの作成 #pubshelf = rospy.Publisher('shelfori',Image, queue_size=10) # Topic「shelfDB」に[detect_object/msg/DBinfo.msg]型のメッセージを送るPublisherの作成 DBpub = rospy.Publisher('shelfDB', DBinfo, queue_size=10) bridge = CvBridge() DBdata = DBinfo() dbcnt = 0 for i in range(20): DBdata.FrameB[i] = Info[i][0] DBdata.FrameT[i] = Info[i][1] DBdata.TimeB[i] = Info[i][2] DBdata.TimeT[i] = Info[i][3] DBdata.id[i] = Info[i][4] DBdata.Xmin[i] = Info[i][5] DBdata.Ymin[i] = Info[i][6] DBdata.Width[i] = Info[i][7] DBdata.Height[i] = Info[i][8] DBdata.Depth[i] = Info[i][9] DBdata.Yobi[i] = 0 DBdata.YobiYobi[i] = 0 if (Info[i][9] == 0): break dbcnt = dbcnt + 1 DBdata.cnt = dbcnt print('DBdataカウント数', DBdata.cnt) for i in range(0, DBdata.cnt): # Topic「shelfimg$i」にImage型のメッセージを送るPublisherの作成 pub[i] = rospy.Publisher('shelfimg' + str(i), Image, queue_size=10) #shelfOri=bridge.cv2_to_imgmsg(shelfCut, encoding="bgr8") for i in range(0, DBdata.cnt): # sqlconnectの返り値をimgmsg形式に変換 msg[i] = bridge.cv2_to_imgmsg(image[i], encoding="bgr8") if (cntone == 0): # まず物体のサイズや座標などの情報をpublish rate = rospy.Rate(0.5) print("Pulish") for k in range(pubcount): DBpub.publish(DBdata) rate.sleep() # 物体の画像をpublish for i in range(pubcount): #pubshelf.publish(shelfOri) for i in range(0, DBdata.cnt): pub[i].publish(msg[i]) rate.sleep() print("finish") print('Wait...') cntone = 1
def imgPublisher(): #sqlconnect関数に入り物体情報を取得 global cntone image = sqlconnect() rospy.init_node('ShelfPub', anonymous=True) pubshelf = rospy.Publisher('shelfori', Image, queue_size=10) DBpub = rospy.Publisher('shelfDB', DBinfo, queue_size=10) bridge = CvBridge() DBdata = DBinfo() idnum = 0 vecnum = 0 dbcnt = 0 # データベースの情報を送信するデータに格納 for i in range(20): DBdata.FrameB[i] = Info[i][0] DBdata.FrameT[i] = Info[i][1] DBdata.TimeB[i] = Info[i][2] DBdata.TimeT[i] = Info[i][3] DBdata.id[i] = Info[i][4] DBdata.Xmin[i] = Info[i][5] DBdata.Ymin[i] = Info[i][6] DBdata.Width[i] = Info[i][7] DBdata.Height[i] = Info[i][8] DBdata.Depth[i] = Info[i][9] DBdata.Yobi[i] = 0 DBdata.YobiYobi[i] = 0 if (Info[i][9] == 0): break dbcnt = dbcnt + 1 DBdata.cnt = dbcnt print(DBdata.cnt) for i in range(0, DBdata.cnt): pub[i] = rospy.Publisher('shelfimg' + str(i), Image, queue_size=10) shelfOri = bridge.cv2_to_imgmsg(shelfCut, encoding="bgr8") for i in range(0, DBdata.cnt): #print(imagenum[i]) msg[i] = bridge.cv2_to_imgmsg(image[i], encoding="bgr8") if (cntone == 0): # まず物体のサイズや座標などの情報をpublish rate = rospy.Rate(0.5) #print(str(Info[0][0])) print("Pulish") for k in range(2): DBpub.publish(DBdata) rate.sleep() # 物体の画像をpublish for i in range(2): pubshelf.publish(shelfOri) for i in range(0, DBdata.cnt): pub[i].publish(msg[i]) rate.sleep() print("finish") print('Wait...') cntone = 1
def imgPublisher(): #sqlconnect関数に入り物体情報を取得 global cntone image = sqlconnect() rospy.init_node('ShelfPub', anonymous=True) if (ids == "true1"): pubshelf = rospy.Publisher('shelfori_1', Image, queue_size=10) elif (ids == "true2"): pubshelf = rospy.Publisher('shelfori_2', Image, queue_size=10) """pub = rospy.Publisher('shelfimg',Image, queue_size=10) pub2 = rospy.Publisher('shelfimg2',Image, queue_size=10) pub3 = rospy.Publisher('shelfimg3',Image, queue_size=10)""" """pub[0]=rospy.Publisher('shelfimg',Image, queue_size=10) pub[1]=rospy.Publisher('shelfimg2',Image, queue_size=10) pub[2]=rospy.Publisher('shelfimg3',Image, queue_size=10)""" #numpub = rospy.Publisher('shelfnum',String, queue_size=10) #if(ids=="true1"): DBpub = rospy.Publisher('shelfDB_1', DBinfo, queue_size=10) #elif(ids=="true2"): # DBpub = rospy.Publisher('shelfDB_2',DBinfo, queue_size=10) bridge = CvBridge() DBdata = DBinfo() idnum = 0 vecnum = 0 dbcnt = 0 for i in range(20): DBdata.FrameB[i] = Info[i][0] DBdata.FrameT[i] = Info[i][1] DBdata.TimeB[i] = Info[i][2] DBdata.TimeT[i] = Info[i][3] DBdata.id[i] = Info[i][4] DBdata.Xmin[i] = Info[i][5] DBdata.Ymin[i] = Info[i][6] DBdata.Width[i] = Info[i][7] DBdata.Height[i] = Info[i][8] DBdata.Depth[i] = Info[i][9] DBdata.Yobi[i] = 0 DBdata.YobiYobi[i] = 0 if (Info[i][9] == 0): break dbcnt = dbcnt + 1 """if(Info[i][1]==idnum): if(Info[i][7]==1): imagenum[vecnum]=i DBdata.WhatNo[vecnum]=i idnum=idnum+1 vecnum=vecnum+1 elif(Info[i][7]==2): idnum=idnum+1""" DBdata.cnt = dbcnt print(DBdata.cnt) #print(DBdata.WhatNo[0]) #print(DBdata.WhatNo[1]) if (ids == "true1"): for i in range(0, DBdata.cnt): pub[i] = rospy.Publisher('shelfimg' + str(i) + '_1', Image, queue_size=10) elif (ids == "true2"): for i in range(0, DBdata.cnt): pub[i] = rospy.Publisher('shelfimg' + str(i) + '_2', Image, queue_size=10) shelfOri = bridge.cv2_to_imgmsg(shelfCut, encoding="bgr8") for i in range(0, DBdata.cnt): #print(imagenum[i]) msg[i] = bridge.cv2_to_imgmsg(image[i], encoding="bgr8") """ print(imagenum[1]) msg2 = bridge.cv2_to_imgmsg(image[imagenum[1]], encoding="bgr8") print(type(image[4])) msg3 = bridge.cv2_to_imgmsg(image[imagenum[2]], encoding="bgr8") """ if (cntone == 0): # まず物体のサイズや座標などの情報をpublish rate = rospy.Rate(0.5) #print(str(Info[0][0])) print("Pulish") for k in range(2): DBpub.publish(DBdata) rate.sleep() # 物体の画像をpublish for i in range(2): pubshelf.publish(shelfOri) for i in range(0, DBdata.cnt): pub[i].publish(msg[i]) rate.sleep() print("finish") print('Wait...') cntone = 1
def imgPublisher(): image = sqlconnect() rospy.init_node('ShelfPub', anonymous=True) pubshelf = rospy.Publisher('shelfori', Image, queue_size=10) """pub = rospy.Publisher('shelfimg',Image, queue_size=10) pub2 = rospy.Publisher('shelfimg2',Image, queue_size=10) pub3 = rospy.Publisher('shelfimg3',Image, queue_size=10)""" """pub[0]=rospy.Publisher('shelfimg',Image, queue_size=10) pub[1]=rospy.Publisher('shelfimg2',Image, queue_size=10) pub[2]=rospy.Publisher('shelfimg3',Image, queue_size=10)""" #numpub = rospy.Publisher('shelfnum',String, queue_size=10) DBpub = rospy.Publisher('shelfDB', DBinfo, queue_size=10) bridge = CvBridge() DBdata = DBinfo() idnum = 0 vecnum = 0 for i in range(20): DBdata.Frame[i] = Info[i][0] DBdata.id[i] = Info[i][1] DBdata.Xmin[i] = Info[i][2] DBdata.Ymin[i] = Info[i][3] DBdata.Width[i] = Info[i][4] DBdata.Height[i] = Info[i][5] DBdata.Depth[i] = Info[i][6] if (Info[i][1] == idnum): if (Info[i][7] == 1): imagenum[vecnum] = i DBdata.WhatNo[vecnum] = i idnum = idnum + 1 vecnum = vecnum + 1 elif (Info[i][7] == 2): idnum = idnum + 1 DBdata.cnt = vecnum print(DBdata.cnt) #print(DBdata.WhatNo[0]) #print(DBdata.WhatNo[1]) for i in range(0, DBdata.cnt): pub[i] = rospy.Publisher('shelfimg' + str(i), Image, queue_size=10) shelfOri = bridge.cv2_to_imgmsg(shelfCut, encoding="bgr8") for i in range(0, DBdata.cnt): #print(imagenum[i]) msg[i] = bridge.cv2_to_imgmsg(image[imagenum[i]], encoding="bgr8") """ print(imagenum[1]) msg2 = bridge.cv2_to_imgmsg(image[imagenum[1]], encoding="bgr8") print(type(image[4])) msg3 = bridge.cv2_to_imgmsg(image[imagenum[2]], encoding="bgr8") """ rate = rospy.Rate(0.5) #print(str(Info[0][0])) print("Pulish") for k in range(2): DBpub.publish(DBdata) rate.sleep() for i in range(2): pubshelf.publish(shelfOri) for i in range(0, DBdata.cnt): pub[i].publish(msg[i]) rate.sleep() print("finish") print('Wait...')