diff --git a/.gitignore b/.gitignore index 9771279..00c879a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .vscode/ .history +*.pyc # Editor directories and files .idea diff --git a/mycobot_ai/CMakeLists.txt b/mycobot_ai/CMakeLists.txt new file mode 100644 index 0000000..a7e50d3 --- /dev/null +++ b/mycobot_ai/CMakeLists.txt @@ -0,0 +1,204 @@ +cmake_minimum_required(VERSION 3.0.2) +project(mycobot_ai) + +## Compile as C++11, supported in ROS Kinetic and newer +# add_compile_options(-std=c++11) + +## Find catkin macros and libraries +## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) +## is used, also find other catkin packages +find_package(catkin REQUIRED COMPONENTS + mycobot_280 +) + +## System dependencies are found with CMake's conventions +# find_package(Boost REQUIRED COMPONENTS system) + + +## Uncomment this if the package has a setup.py. This macro ensures +## modules and global scripts declared therein get installed +## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html +# catkin_python_setup() + +################################################ +## Declare ROS messages, services and actions ## +################################################ + +## To declare and build messages, services or actions from within this +## package, follow these steps: +## * Let MSG_DEP_SET be the set of packages whose message types you use in +## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). +## * In the file package.xml: +## * add a build_depend tag for "message_generation" +## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET +## * If MSG_DEP_SET isn't empty the following dependency has been pulled in +## but can be declared for certainty nonetheless: +## * add a exec_depend tag for "message_runtime" +## * In this file (CMakeLists.txt): +## * add "message_generation" and every package in MSG_DEP_SET to +## find_package(catkin REQUIRED COMPONENTS ...) +## * add "message_runtime" and every package in MSG_DEP_SET to +## catkin_package(CATKIN_DEPENDS ...) +## * uncomment the add_*_files sections below as needed +## and list every .msg/.srv/.action file to be processed +## * uncomment the generate_messages entry below +## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) + +## Generate messages in the 'msg' folder +# add_message_files( +# FILES +# Message1.msg +# Message2.msg +# ) + +## Generate services in the 'srv' folder +# add_service_files( +# FILES +# Service1.srv +# Service2.srv +# ) + +## Generate actions in the 'action' folder +# add_action_files( +# FILES +# Action1.action +# Action2.action +# ) + +## Generate added messages and services with any dependencies listed here +# generate_messages( +# DEPENDENCIES +# std_msgs # Or other packages containing msgs +# ) + +################################################ +## Declare ROS dynamic reconfigure parameters ## +################################################ + +## To declare and build dynamic reconfigure parameters within this +## package, follow these steps: +## * In the file package.xml: +## * add a build_depend and a exec_depend tag for "dynamic_reconfigure" +## * In this file (CMakeLists.txt): +## * add "dynamic_reconfigure" to +## find_package(catkin REQUIRED COMPONENTS ...) +## * uncomment the "generate_dynamic_reconfigure_options" section below +## and list every .cfg file to be processed + +## Generate dynamic reconfigure parameters in the 'cfg' folder +# generate_dynamic_reconfigure_options( +# cfg/DynReconf1.cfg +# cfg/DynReconf2.cfg +# ) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## INCLUDE_DIRS: uncomment this if your package contains header files +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( +# INCLUDE_DIRS include +# LIBRARIES mycobot_ai +# CATKIN_DEPENDS mycobot_280 +# DEPENDS system_lib +) + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +include_directories( +# include + ${catkin_INCLUDE_DIRS} +) + +## Declare a C++ library +# add_library(${PROJECT_NAME} +# src/${PROJECT_NAME}/mycobot_ai.cpp +# ) + +## Add cmake target dependencies of the library +## as an example, code may need to be generated before libraries +## either from message generation or dynamic reconfigure +# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Declare a C++ executable +## With catkin_make all packages are built within a single CMake context +## The recommended prefix ensures that target names across packages don't collide +# add_executable(${PROJECT_NAME}_node src/mycobot_ai_node.cpp) + +## Rename C++ executable without prefix +## The above recommended prefix causes long target names, the following renames the +## target back to the shorter version for ease of user use +## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node" +# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "") + +## Add cmake target dependencies of the executable +## same as for the library above +# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Specify libraries to link a library or executable target against +# target_link_libraries(${PROJECT_NAME}_node +# ${catkin_LIBRARIES} +# ) + +############# +## Install ## +############# + +# all install targets should use catkin DESTINATION variables +# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html + +## Mark executable scripts (Python etc.) for installation +## in contrast to setup.py, you can choose the destination +# catkin_install_python(PROGRAMS +# scripts/my_python_script +# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark executables for installation +## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html +# install(TARGETS ${PROJECT_NAME}_node +# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark libraries for installation +## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html +# install(TARGETS ${PROJECT_NAME} +# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} +# ) + +## Mark cpp header files for installation +# install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +# FILES_MATCHING PATTERN "*.h" +# PATTERN ".svn" EXCLUDE +# ) + +## Mark other files for installation (e.g. launch and bag files, etc.) +# install(FILES +# # myfile1 +# # myfile2 +# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +# ) + +############# +## Testing ## +############# + +## Add gtest based cpp test target and link libraries +# catkin_add_gtest(${PROJECT_NAME}-test test/test_mycobot_ai.cpp) +# if(TARGET ${PROJECT_NAME}-test) +# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) +# endif() + +## Add folders to be run by python nosetests +# catkin_add_nosetests(test) diff --git a/mycobot_ai/launch/vision.launch b/mycobot_ai/launch/vision.launch new file mode 100644 index 0000000..654f540 --- /dev/null +++ b/mycobot_ai/launch/vision.launch @@ -0,0 +1,27 @@ + + + + + + + + + + + + + ["joint_states"] + + + + + + + + + + + + + + diff --git a/mycobot_ai/local_photo/img/goal01.jpeg b/mycobot_ai/local_photo/img/goal01.jpeg new file mode 100644 index 0000000..1c5b153 Binary files /dev/null and b/mycobot_ai/local_photo/img/goal01.jpeg differ diff --git a/mycobot_ai/local_photo/img/goal02.jpeg b/mycobot_ai/local_photo/img/goal02.jpeg new file mode 100644 index 0000000..0d6c5c5 Binary files /dev/null and b/mycobot_ai/local_photo/img/goal02.jpeg differ diff --git a/mycobot_ai/local_photo/img/goal03.jpeg b/mycobot_ai/local_photo/img/goal03.jpeg new file mode 100644 index 0000000..a6566fb Binary files /dev/null and b/mycobot_ai/local_photo/img/goal03.jpeg differ diff --git a/mycobot_ai/local_photo/img/goal04.jpeg b/mycobot_ai/local_photo/img/goal04.jpeg new file mode 100644 index 0000000..d20e4ef Binary files /dev/null and b/mycobot_ai/local_photo/img/goal04.jpeg differ diff --git a/mycobot_ai/package.xml b/mycobot_ai/package.xml new file mode 100644 index 0000000..239106b --- /dev/null +++ b/mycobot_ai/package.xml @@ -0,0 +1,62 @@ + + + mycobot_ai + 0.0.0 + The mycobot_ai package + + + + + huang + + + + + + TODO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + catkin + mycobot_280 + mycobot_280 + mycobot_280 + + + + + + + + diff --git a/mycobot_ai/scripts/add_img.py b/mycobot_ai/scripts/add_img.py new file mode 100644 index 0000000..0ea294a --- /dev/null +++ b/mycobot_ai/scripts/add_img.py @@ -0,0 +1,89 @@ +# coding:utf-8 +import os, cv2, sys + + +def take_photo(): + # 提醒用户操作字典 + print("*********************************************") + print("* 热键(请在摄像头的窗口使用): *") + print("* z: 拍摄图片 *") + print("* q: 退出 *") + print("*********************************************") + + # 创建/使用local_photo文件夹 + class_name = "local_photo" + if (os.path.exists("local_photo")): + pass + else: + os.mkdir(class_name) + + # 设置特定值 + + index = 'takephoto' + cap = cv2.VideoCapture(0) + + while True: + # 读入每一帧 + ret, frame = cap.read() + + cv2.imshow("capture", frame) + + # 存储 + input = cv2.waitKey(1) & 0xFF + # 拍照 + if input == ord('z'): + cv2.imwrite( + "%s/%s.jpeg" % (class_name, index), + cv2.resize(frame, (600, 480), interpolation=cv2.INTER_AREA)) + break + + # 退出 + if input == ord('q'): + + # 关闭窗口 + cap.release() + cv2.destroyAllWindows() + sys.exit() + + +def cut_photo(): + path = os.getcwd() + '/local_photo/img' + for i, j, k in os.walk(path): + file_len = len(k) + print("请截取要识别的部分") + # root = tk.Tk() + # root.withdraw() + # temp1=filedialog.askopenfilename(parent=root) #rgb + # temp2=Image.open(temp1,mode='r') + # temp2= cv.cvtColor(np.asarray(temp2),cv.COLOR_RGB2BGR) + # cut = np.array(temp2) + + cut = cv2.imread(r"local_photo/takephoto.jpeg") + + cv2.imshow('original', cut) + # C:\Users\Elephant\Desktop\pymycobot+opencv\local_photo/takephoto.jpeg + + # 选择ROI + roi = cv2.selectROI(windowName="original", + img=cut, + showCrosshair=False, + fromCenter=False) + x, y, w, h = roi + print(roi) + + # 显示ROI并保存图片 + if roi != (0, 0, 0, 0): + crop = cut[y:y + h, x:x + w] + cv2.imshow('crop', crop) + cv2.imwrite('local_photo/img/goal{}.jpeg'.format(str(file_len + 1)), + crop) + print('Saved!') + + # 退出 + cv2.waitKey(0) + cv2.destroyAllWindows() + + +if __name__ == "__main__": + take_photo() + cut_photo() diff --git a/mycobot_ai/scripts/ai_windows.py b/mycobot_ai/scripts/ai_windows.py new file mode 100644 index 0000000..340ecec --- /dev/null +++ b/mycobot_ai/scripts/ai_windows.py @@ -0,0 +1,178 @@ +#!/usr/bin/env python3 +# encoding:utf-8 + +from tkinter import ttk +from tkinter import * +import os, time + +import threading +from multiprocessing import Process + + +class Application(object): + def __init__(self): + self.win = Tk() + # 窗口置顶 + self.win.wm_attributes('-topmost', 1) + self.ros = False + # 运行的文件 + self.run_py = "" + # 判断通信口并给权限 + try: + self.ports = os.popen("ls /dev/ttyUSB*").readline() + if "dev" not in self.ports: + self.ports = os.popen("ls /dev/ttyACM*").readline()[:-1] + self.command = ''.format( + self.ports) + # 根据通信口修改ros启动文件 + os.system( + "sed -i '2c {}' /home/h/catkin_mycobot/src/mycobot_ros/mycobot_ai/launch/vision.launch" + .format(self.command)) + except Exception as e: + pass + + # 设置标题 + self.win.title("aikit启动工具") + self.win.geometry( + "500x300+100+100") # 290 160为窗口大小,+10 +10 定义窗口弹出时的默认展示位置 + # 打开ros按钮 + self.btn = Button(self.win, text="open ROS", command=self.open_ros) + self.btn.grid(row=0) + + self.chanse_code = Label(self.win, text="选择程序:", width=10) + self.chanse_code.grid(row=1) + + self.myComboList = [u"颜色识别", u"物体识别", u"二维码识别"] + self.myCombox = ttk.Combobox(self.win, values=self.myComboList) + self.myCombox.grid(row=1, column=1) + + self.add_btn = Button(self.win, text="添加新的物体图像", command=self.add_img) + self.add_btn.grid(row=1, column=2) + + # self.set_xy = Label(self.win, text="set_xy:", width=10) + # self.set_xy.grid(row=1) + + # self.x = Label(self.win, text="x:") + # self.x.grid(row=2) + # self.v1 = StringVar() + # self.e1 = Entry(self.win,textvariable=self.v1, width=10) + # self.e1.insert(0,0) + # self.e1.grid(row=2,column=1) + + # self.y = Label(self.win, text="y:") + # self.y.grid(row=3) + # self.v2 = StringVar() + # self.e2 = Entry(self.win,textvariable=self.v2, width=10) + # self.e2.insert(0,0) + # self.e2.grid(row=3,column=1) + self.tips = "1、首先打开ros\n2、选择所要运行的程序点击运行即可" + + self.btn = Button(self.win, text="运行", command=self.start_run) + self.btn.grid(row=5) + + self.close = Button(self.win, text="close", command=self.close_py) + self.close.grid(row=5, column=1) + + self.t2 = None + self.log_data = Text(self.win, width=66, height=10) + self.log_data.grid(row=16, column=0, columnspan=10) + self.log_data.insert(END, self.tips) + # self.code_list = ttk.Combobox(self.win, width=15) + # self.code_list["value"] = ("颜色识别", "物体识别", "二维码识别") + # self.code_list.current(0) + # self.code_list.grid(row=1, column=1) + + def start_run(self): + try: + print(u"开始运行") + one = self.myCombox.get() + if one == u"颜色识别": + t2 = threading.Thread(target=self.open_py1) + t2.setDaemon(True) + t2.start() + elif one == u"物体识别": + self.run_py = "detect_obj_img.py" + t3 = threading.Thread(target=self.open_py) + t3.setDaemon(True) + t3.start() + elif one == u"二维码识别": + self.run_py = "detect_encode.py" + t3 = threading.Thread(target=self.open_py2) + t3.setDaemon(True) + t3.start() + except Exception as e: + self.tips = str(e) + self.log_data.insert(END, self.tips) + + def open_py(self): + os.system( + "python /home/h/catkin_mycobot/src/mycobot_ros/mycobot_ai/scripts/detect_obj_img.py" + ) + + def open_py1(self): + os.system( + "python /home/h/catkin_mycobot/src/mycobot_ros/mycobot_ai/scripts/detect_obj_color.py" + ) + + def open_py2(self): + os.system( + "python /home/h/catkin_mycobot/src/mycobot_ros/mycobot_ai/scripts/detect_encode.py" + ) + + def add_img(self): + os.system( + "python /home/h/catkin_mycobot/src/mycobot_ros/mycobot_ai/scripts/add_img.py" + ) + + def open_ros(self): + if self.ros: + print("ros is opened") + return + t1 = threading.Thread(target=self.ross) + t1.setDaemon(True) + t1.start() + self.ros = True + + def ross(self): + os.system( + "roslaunch ~/catkin_mycobot/src/mycobot_ros/mycobot_ai/launch/vision.launch" + ) + + def close_py(self): + t1 = threading.Thread(target=self.close_p) + t1.setDaemon(True) + t1.start() + + def close_p(self): + # 关闭ai程序 + os.system("ps -ef | grep -E " + self.run_py + + " | grep -v 'grep' | awk '{print $2}' | xargs kill -9") + + def get_current_time(self): + # 日志时间 + """Get current time with format.""" + current_time = time.strftime("%Y-%m-%d %H:%M:%S", + time.localtime(time.time())) + return current_time + + def write_log_to_Text(self, logmsg): + # 设置日志函数 + global LOG_NUM + current_time = self.get_current_time() + logmsg_in = str(current_time) + " " + str(logmsg) + "\n" # 换行 + + if LOG_NUM <= 18: + self.log_data_Text.insert(END, logmsg_in) + LOG_NUM += len(logmsg_in.split("\n")) + # print(LOG_NUM) + else: + self.log_data_Text.insert(END, logmsg_in) + self.log_data_Text.yview("end") + + def run(self): + self.win.mainloop() + + +if __name__ == "__main__": + mc = Application() + mc.run() diff --git a/mycobot_ai/scripts/detect_encode.py b/mycobot_ai/scripts/detect_encode.py new file mode 100644 index 0000000..18b1cd2 --- /dev/null +++ b/mycobot_ai/scripts/detect_encode.py @@ -0,0 +1,197 @@ +#encoding: UTF-8 +#!/usr/bin/env python2 +import cv2 as cv +import os +import numpy as np +import time +import rospy +from visualization_msgs.msg import Marker +from moving_utils import Movement + +# y轴偏移量 +pump_y = -55 +# x轴偏移量 +pump_x = 15 + +class Detect_marker(Movement): + def __init__(self): + super(Detect_marker, self).__init__() + # set cache of real coord + self.cache_x = self.cache_y = 0 + + # which robot + self.robot = os.popen("ls /dev/ttyUSB*") + if "dev" in self.robot: + self.Pin = [2,5] + else: + self.Pin = [20,21] + + # Creating a Camera Object + cap_num = 0 + self.cap = cv.VideoCapture(cap_num) + # Get ArUco marker dict that can be detected. + self.aruco_dict = cv.aruco.Dictionary_get(cv.aruco.DICT_6X6_250) + # Get ArUco marker params. + self.aruco_params = cv.aruco.DetectorParameters_create() + self.calibrationParams = cv.FileStorage("calibrationFileName.xml", cv.FILE_STORAGE_READ) + # Get distance coefficient. + self.dist_coeffs = self.calibrationParams.getNode("distCoeffs").mat() + + height = self.cap.get(4) + focal_length = width = self.cap.get(3) + center = [width / 2, height / 2] + # Calculate the camera matrix. + self.camera_matrix = np.array( + [ + [focal_length, 0, center[0]], + [0, focal_length, center[1]], + [0, 0, 1], + ], + dtype=np.float32, + ) + # init a node and a publisher + rospy.init_node("encode_marker", anonymous=True) + self.pub = rospy.Publisher('/cube', Marker, queue_size=1) + + self.marker = Marker() + self.marker.header.frame_id = "/joint1" + self.marker.ns = "cube" + self.marker.type = self.marker.CUBE + self.marker.action = self.marker.ADD + self.marker.scale.x = 0.04 + self.marker.scale.y = 0.04 + self.marker.scale.z = 0.04 + self.marker.color.a = 1 + self.marker.color.r = 0.3 + self.marker.color.g = 0.3 + self.marker.color.b = 0.3 + + + # marker position initial + self.marker.pose.position.x = 0 + self.marker.pose.position.y = 0 + self.marker.pose.position.z = 0.03 + self.marker.pose.orientation.x = 0 + self.marker.pose.orientation.y = 0 + self.marker.pose.orientation.z = 0 + self.marker.pose.orientation.w = 1.0 + + # Grasping motion + def move(self, x, y): + + coords = [ + [135.0, -65.5, 280.1, 178.99, 5.38, -179.9], + [136.1, -141.6, 243.9, 178.99, 5.38, -179.9] + ] + + # publish marker + self.marker.header.stamp = rospy.Time.now() + self.marker.pose.position.x = (coords[0][0]-x)/1000.0 + self.marker.pose.position.y = (coords[0][1]-y)/1000.0 + self.pub.publish(self.marker) + + # send coordinates to move mycobot + self.pub_coords(coords[0], 30, 1) + time.sleep(2) + self.pub_coords([coords[0][0]-x, coords[0][1]-y, 240, 178.99, 5.38, -179.9], 25, 1) + time.sleep(2) + self.pub_coords([coords[0][0]-x, coords[0][1]-y, 200, 178.99, 5.38, -179.9], 25, 1) + time.sleep(2) + if "dev" in self.robot: + self.pub_coords([coords[0][0]-x, coords[0][1]-y, 90, 178.99, 5.38, -179.9], 25, 1) + else: + self.pub_coords([coords[0][0]-x+20, coords[0][1]-y-10, 70, 178.99, 5.38, -179.9], 25, 1) + time.sleep(3.5) + self.pub_pump(True,self.Pin) + self.pub_coords(coords[0], 30, 1) + time.sleep(3) + self.pub_coords(coords[1], 30, 1) + time.sleep(2) + self.pub_pump(False,self.Pin) + # publish marker + self.marker.header.stamp = rospy.Time.now() + self.marker.pose.position.x = coords[1][0]/1000.0 + self.marker.pose.position.y = coords[1][1]/1000.0 + self.pub.publish(self.marker) + + self.pub_coords(coords[0], 30, 1) + time.sleep(2) + + # decide whether grab cube + def decide_move(self, x, y): + + print(x,y) + # detect the cube status move or run + if (abs(x - self.cache_x) + abs(y - self.cache_y)) / 2 > 5: # mm + self.cache_x, self.cache_y = x, y + return + else: + self.cache_x = self.cache_y = 0 + self.move(x, y) + + # init mycobot + def init_mycobot(self): + self.pub_pump(False,self.Pin) + for _ in range(5): + print _ + self.pub_coords([135.0, -65.5, 280.1, 178.99, 5.38, -179.9], 20, 1) + time.sleep(0.5) + + + + def run(self): + global pump_y, pump_x + self.init_mycobot() + num = sum_x = sum_y = 0 + while cv.waitKey(1) < 0: + success, img = self.cap.read() + if not success: + print("It seems that the image cannot be acquired correctly.") + break + + # transfrom the img to model of gray + gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY) + # Detect ArUco marker. + corners, ids, rejectImaPoint = cv.aruco.detectMarkers( + gray, self.aruco_dict, parameters=self.aruco_params + ) + + if len(corners) > 0: + if ids is not None: + # get informations of aruco + ret = cv.aruco.estimatePoseSingleMarkers( + corners, 0.03, self.camera_matrix, self.dist_coeffs + ) + # rvec:rotation offset,tvec:translation deviator + (rvec, tvec) = (ret[0], ret[1]) + (rvec - tvec).any() + xyz = tvec[0, 0, :] + # calculate the coordinates of the aruco relative to the pump + xyz = [round(xyz[0]*1000+pump_y, 2), round(xyz[1]*1000+pump_x, 2), round(xyz[2]*1000, 2)] + + + for i in range(rvec.shape[0]): + # draw the aruco on img + cv.aruco.drawDetectedMarkers(img, corners) + cv.aruco.drawAxis( + img, + self.camera_matrix, + self.dist_coeffs, + rvec[i, :, :], + tvec[i, :, :], + 0.03, + ) + + if num < 40 : + sum_x += xyz[1] + sum_y += xyz[0] + num += 1 + elif num ==40 : + self.decide_move(sum_x/40.0, sum_y/40.0) + num = sum_x = sum_y = 0 + + cv.imshow("encode_image", img) + +if __name__ == "__main__": + detect = Detect_marker() + detect.run() diff --git a/mycobot_ai/scripts/detect_obj_color.py b/mycobot_ai/scripts/detect_obj_color.py new file mode 100644 index 0000000..ccd4fae --- /dev/null +++ b/mycobot_ai/scripts/detect_obj_color.py @@ -0,0 +1,432 @@ +#encoding:utf-8 + +from tokenize import Pointfloat +import cv2 +import numpy as np +import time +import json +import os +import rospy +from visualization_msgs.msg import Marker + +from moving_utils import Movement + +IS_CV_4 = cv2.__version__[0] == '4' +__version__ = "1.0" +# Adaptive seeed + +class Object_detect(Movement): + + def __init__(self, camera_x=150, camera_y=-10): + # inherit the parent class + super(Object_detect, self).__init__() + # get path of file + dir_path = os.path.dirname(__file__) + # 移动角度 + self.move_angles = [ + [-7.11, -6.94, -55.01, -24.16, 0, -38.84], # init the point + [-1.14, -10.63, -87.8, 9.05, -3.07, -37.7], # point to grab + [17.4, -10.1, -87.27, 5.8, -2.02, -37.7], # point to grab + ] + # 移动坐标 + self.move_coords = [ + [120.1, -141.6, 240.9, -173.34, -8.15, -83.11], # above the red bucket + [228.2, -127.8, 260.9, -157.51, -17.5, -71.18], # above the yello bucket + [209.7, -18.6, 230.4, -168.48, -9.86, -39.38], + [196.9, -64.7, 232.6, -166.66, -9.44, -52.47], + [126.6, -118.1, 305.0, -157.57, -13.72, -75.3], + ] + # which robot + self.robot = os.popen("ls /dev/ttyUSB*") + if "dev" in self.robot: + self.Pin = [2,5] + else: + self.Pin = [20,21] + for i in self.move_coords: + i[2] -= 20 + + # choose place to set cube + self.color = 0 + # parameters to calculate camera clipping parameters + self.x1 = self.x2 = self.y1 = self.y2 =0 + # set cache of real coord + self.cache_x = self.cache_y = 0 + # set color HSV + self.HSV = { + "yellow": [np.array([11, 115, 70]), np.array([40, 255, 245])], + "red": [np.array([0, 43, 46]), np.array([8, 255, 255])], + "green": [np.array([35, 43, 46]), np.array([77, 255, 255])], + "blue": [np.array([100, 43, 46]), np.array([124, 255, 255])], + "cyan": [np.array([78, 43, 46]), np.array([99, 255, 255])], + } + # use to calculate coord between cube and mycobot + self.sum_x1= self.sum_x2= self.sum_y2= self.sum_y1= 0 + # The coordinates of the grab center point relative to the mycobot + self.camera_x, self.camera_y = camera_x, camera_y + # The coordinates of the cube relative to the mycobot + self.c_x, self.c_y = 0,0 + # The ratio of pixels to actual values + self.ratio = 0 + # Get ArUco marker dict that can be detected. + self.aruco_dict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_6X6_250) + # Get ArUco marker params. + self.aruco_params = cv2.aruco.DetectorParameters_create() + + # init a node and a publisher + rospy.init_node("marker", anonymous=True) + self.pub = rospy.Publisher('/cube', Marker, queue_size=1) + # init a Marker + self.marker = Marker() + self.marker.header.frame_id = "/joint1" + self.marker.ns = "cube" + self.marker.type = self.marker.CUBE + self.marker.action = self.marker.ADD + self.marker.scale.x = 0.04 + self.marker.scale.y = 0.04 + self.marker.scale.z = 0.04 + self.marker.color.a = 1.0 + self.marker.color.g = 1.0 + self.marker.color.r = 1.0 + + + # marker position initial + self.marker.pose.position.x = 0 + self.marker.pose.position.y = 0 + self.marker.pose.position.z = 0.03 + self.marker.pose.orientation.x = 0 + self.marker.pose.orientation.y = 0 + self.marker.pose.orientation.z = 0 + self.marker.pose.orientation.w = 1.0 + + # publish marker + def pub_marker(self, x, y , z=0.03): + self.marker.header.stamp = rospy.Time.now() + self.marker.pose.position.x = x + self.marker.pose.position.y = y + self.marker.pose.position.z = z + self.marker.color.g = self.color + self.pub.publish(self.marker) + + # Grasping motion + def move(self, x,y,color): + # send Angle to move mycobot + print color + self.pub_angles(self.move_angles[0], 20) + time.sleep(1.5) + self.pub_angles(self.move_angles[1], 20) + time.sleep(1.5) + self.pub_angles(self.move_angles[2], 20) + time.sleep(1.5) + # send coordinates to move mycobot + self.pub_coords([x, y, 165, -178.9, -1.57, -25.95], 20, 1) + time.sleep(1.5) + if "dev" in self.robot: + self.pub_coords([x, y, 90, -178.9, -1.57, -25.95], 20, 1) + else: + + h = 0 + + if 165180: + h = 20 + elif x<135: + h = -20 + print 'down_1:',[x, y, 31.9+h, -178.9, -1, -25.95] + self.pub_coords([x, y, 31.9+h, -178.9, -1, -25.95], 20, 1) + time.sleep(1.5) + # open pump + self.pub_pump(True,self.Pin) + time.sleep(0.5) + self.pub_angles(self.move_angles[2], 20) + time.sleep(3) + self.pub_marker(self.move_coords[2][0]/1000.0, self.move_coords[2][1]/1000.0, self.move_coords[2][2]/1000.0) + + self.pub_angles(self.move_angles[1], 20) + time.sleep(1.5) + self.pub_marker(self.move_coords[3][0]/1000.0, self.move_coords[3][1]/1000.0, self.move_coords[3][2]/1000.0) + + self.pub_angles(self.move_angles[0], 20) + time.sleep(2) + self.pub_marker(self.move_coords[4][0]/1000.0, self.move_coords[4][1]/1000.0, self.move_coords[4][2]/1000.0) + + print 'down:',self.move_coords[color] + self.pub_coords(self.move_coords[color], 20, 1) + self.pub_marker(self.move_coords[color][0]/1000.0, self.move_coords[color][1]/1000.0, self.move_coords[color][2]/1000.0) + time.sleep(2) + # close pump + self.pub_pump(False,self.Pin) + if color==1: + self.pub_marker(self.move_coords[color][0]/1000.0+0.04, self.move_coords[color][1]/1000.0-0.02) + elif color==0: + self.pub_marker(self.move_coords[color][0]/1000.0+0.03, self.move_coords[color][1]/1000.0) + self.pub_angles(self.move_angles[0], 20) + time.sleep(3) + + + # decide whether grab cube + def decide_move(self, x, y, color): + + + print(x, y,self.cache_x, self.cache_y) + # detect the cube status move or run + if (abs(x - self.cache_x) + abs(y - self.cache_y)) / 2 > 5: # mm + self.cache_x, self.cache_y = x, y + return + else: + self.cache_x = self.cache_y = 0 + if "dev" not in self.robot: + + if (y<-30 and x>140) or (x>150 and y<-10): + x -= 10 + y += 10 + elif y>-10: + y += 10 + elif x>170: + x -=10 + y +=10 + print x,y + self.move(x,y,color) + + # init mycobot + def run(self): + + for _ in range(10): + self.pub_angles([-7.11, -6.94, -55.01, -24.16, 0, -38.84], 20) + print(_) + time.sleep(0.5) + self.pub_pump(False,self.Pin) + + # draw aruco + def draw_marker(self,img,x,y): + # draw rectangle on img + cv2.rectangle( + img, + (x - 20, y - 20), + (x + 20, y + 20), + (0, 255, 0), + thickness=2, + lineType=cv2.FONT_HERSHEY_COMPLEX, + ) + # add text on rectangle + cv2.putText(img,"({},{})".format(x,y),(x,y),cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (243, 0, 0), 2,) + + # get points of two aruco + def get_calculate_params(self,img): + # Convert the image to a gray image + gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + # Detect ArUco marker. + corners, ids, rejectImaPoint = cv2.aruco.detectMarkers( + gray, self.aruco_dict, parameters=self.aruco_params + ) + + """ + Two Arucos must be present in the picture and in the same order. + There are two Arucos in the Corners, and each aruco contains the pixels of its four corners. + Determine the center of the aruco by the four corners of the aruco. + """ + if len(corners) > 0: + if ids is not None: + if len(corners) <= 1 or ids[0]==1: + return None + x1=x2=y1=y2 = 0 + point_11,point_21,point_31,point_41 = corners[0][0] + x1, y1 = int((point_11[0] + point_21[0] + point_31[0] + point_41[0]) / 4.0), int((point_11[1] + point_21[1] + point_31[1] + point_41[1]) / 4.0) + point_1,point_2,point_3,point_4 = corners[1][0] + x2, y2 = int((point_1[0] + point_2[0] + point_3[0] + point_4[0]) / 4.0), int((point_1[1] + point_2[1] + point_3[1] + point_4[1]) / 4.0) + return x1,x2,y1,y2 + return None + + # set camera clipping parameters + def set_cut_params(self, x1, y1, x2, y2): + self.x1 = int(x1) + self.y1 = int(y1) + self.x2 = int(x2) + self.y2 = int(y2) + print(self.x1,self.y1,self.x2,self.y2) + + # set parameters to calculate the coords between cube and mycobot + def set_params(self, c_x, c_y, ratio): + self.c_x = c_x + self.c_y = c_y + self.ratio = 220.0/ratio + + # calculate the coords between cube and mycobot + def get_position(self, x, y): + return ((y - self.c_y)*self.ratio + self.camera_x), ((x - self.c_x)*self.ratio + self.camera_y) + + """ + Calibrate the camera according to the calibration parameters. + Enlarge the video pixel by 1.5 times, which means enlarge the video size by 1.5 times. + If two ARuco values have been calculated, clip the video. + """ + def transform_frame(self, frame): + # enlarge the image by 1.5 times + fx = 1.5 + fy = 1.5 + frame = cv2.resize(frame, (0, 0), fx=fx, fy=fy, interpolation=cv2.INTER_CUBIC) + if self.x1 != self.x2: + # the cutting ratio here is adjusted according to the actual situation + frame = frame[int(self.y2*0.2):int(self.y1*1.15), int(self.x1*0.7):int(self.x2*1.15)] + return frame + + # detect cube color + def color_detect(self, img): + # set the arrangement of color'HSV + x = y = 0 + for mycolor, item in self.HSV.items(): + redLower = np.array(item[0]) + redUpper = np.array(item[1]) + # transfrom the img to model of gray + hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) + # wipe off all color expect color in range + mask = cv2.inRange(hsv, item[0], item[1]) + # a etching operation on a picture to remove edge roughness + erosion = cv2.erode(mask, np.ones((1, 1), np.uint8), iterations=2) + # the image for expansion operation, its role is to deepen the color depth in the picture + dilation =cv2.dilate(erosion, np.ones((1, 1), np.uint8), iterations=2) + # adds pixels to the image + target = cv2.bitwise_and(img, img, mask=dilation) + # the filtered image is transformed into a binary image and placed in binary + ret, binary = cv2.threshold(dilation, 127, 255, cv2.THRESH_BINARY) + # get the contour coordinates of the image, where contours is the coordinate value, here only the contour is detected + contours, hierarchy = cv2.findContours( + dilation, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) + + if len(contours) > 0: + # do something about misidentification + boxes = [ + box + for box in [cv2.boundingRect(c) for c in contours] + if min(img.shape[0], img.shape[1]) / 10 + < min(box[2], box[3]) + < min(img.shape[0], img.shape[1]) / 1 + ] + if boxes: + for box in boxes: + x, y, w, h = box + # find the largest object that fits the requirements + c = max(contours, key=cv2.contourArea) + # get the lower left and upper right points of the positioning object + x, y, w, h = cv2.boundingRect(c) + # locate the target by drawing rectangle + cv2.rectangle(img, (x, y), (x+w, y+h), (153, 153, 0), 2) + # calculate the rectangle center + x, y = (x*2+w)/2, (y*2+h)/2 + # calculate the real coordinates of mycobot relative to the target + if mycolor == "yellow": + self.color = 1 + elif mycolor == "red": + self.color = 0 + else: + self.color = 1 + + if abs(x) + abs(y) > 0: + return x, y + else: + return None + + + + +if __name__ == "__main__": + # open the camera + cap_num = 0 + cap = cv2.VideoCapture(cap_num) + if not cap.isOpened(): + cap.open() + # init a class of Object_detect + detect = Object_detect() + # init mycobot + detect.run() + + _init_ = 20 # + init_num = 0 + nparams = 0 + num = 0 + real_sx = real_sy = 0 + while cv2.waitKey(1) < 0: + # read camera + _,frame = cap.read() + # deal img + frame = detect.transform_frame(frame) + + + if _init_ > 0: + _init_-=1 + continue + # calculate the parameters of camera clipping + if init_num < 20: + if detect.get_calculate_params(frame) is None: + cv2.imshow("figure",frame) + continue + else: + x1,x2,y1,y2 = detect.get_calculate_params(frame) + detect.draw_marker(frame,x1,y1) + detect.draw_marker(frame,x2,y2) + detect.sum_x1+=x1 + detect.sum_x2+=x2 + detect.sum_y1+=y1 + detect.sum_y2+=y2 + init_num+=1 + continue + elif init_num==20: + detect.set_cut_params( + (detect.sum_x1)/20.0, + (detect.sum_y1)/20.0, + (detect.sum_x2)/20.0, + (detect.sum_y2)/20.0, + ) + detect.sum_x1 = detect.sum_x2 = detect.sum_y1 = detect.sum_y2 = 0 + init_num+=1 + continue + + # calculate params of the coords between cube and mycobot + if nparams < 10: + if detect.get_calculate_params(frame) is None: + cv2.imshow("figure",frame) + continue + else: + x1,x2,y1,y2 = detect.get_calculate_params(frame) + detect.draw_marker(frame,x1,y1) + detect.draw_marker(frame,x2,y2) + detect.sum_x1+=x1 + detect.sum_x2+=x2 + detect.sum_y1+=y1 + detect.sum_y2+=y2 + nparams+=1 + continue + elif nparams==10: + nparams+=1 + # calculate and set params of calculating real coord between cube and mycobot + detect.set_params( + (detect.sum_x1+detect.sum_x2)/20.0, + (detect.sum_y1+detect.sum_y2)/20.0, + abs(detect.sum_x1-detect.sum_x2)/10.0+abs(detect.sum_y1-detect.sum_y2)/10.0 + ) + print "ok" + continue + + # get detect result + detect_result = detect.color_detect(frame) + if detect_result is None: + cv2.imshow("figure",frame) + continue + else: + x, y = detect_result + # calculate real coord between cube and mycobot + real_x, real_y = detect.get_position(x, y) + if num == 20: + detect.pub_marker(real_sx/20.0/1000.0, real_sy/20.0/1000.0) + detect.decide_move(real_sx/20.0, real_sy/20.0, detect.color) + num = real_sx = real_sy = 0 + + else: + num += 1 + real_sy += real_y + real_sx += real_x + + cv2.imshow("figure",frame) + + + diff --git a/mycobot_ai/scripts/detect_obj_img.py b/mycobot_ai/scripts/detect_obj_img.py new file mode 100644 index 0000000..d42ab21 --- /dev/null +++ b/mycobot_ai/scripts/detect_obj_img.py @@ -0,0 +1,602 @@ +#encoding:utf-8 + +from tokenize import Pointfloat +import cv2 +import numpy as np +import time +import json +import os +import rospy +from visualization_msgs.msg import Marker +from PIL import Image +from threading import Thread +import tkFileDialog as filedialog +import Tkinter as tk +from moving_utils import Movement + +IS_CV_4 = cv2.__version__[0] == '4' +__version__ = "1.0" # Adaptive seeed + +class Object_detect(Movement): + def __init__(self, camera_x=150, camera_y=-10): + # inherit the parent class + super(Object_detect, self).__init__() + # get path of file + dir_path = os.path.dirname(__file__) + # 移动角度 + self.move_angles = [ + [-7.11, -6.94, -55.01, -24.16, 0, -38.84], # init the point + [-1.14, -10.63, -87.8, 9.05, -3.07, -37.7], # point to grab + [17.4, -10.1, -87.27, 5.8, -2.02, -37.7], # point to grab + ] + # 移动坐标 + self.move_coords = [ + [120.1, -141.6, 240.9, -173.34, -8.15, -83.11], # above the red bucket + [228.2, -127.8, 260.9, -157.51, -17.5, -71.18], # above the yello bucket + [209.7, -18.6, 230.4, -168.48, -9.86, -39.38], + [196.9, -64.7, 232.6, -166.66, -9.44, -52.47], + [126.6, -118.1, 305.0, -157.57, -13.72, -75.3], + ] + # 判断连接设备:ttyUSB*为M5,ttyACM*为seeed + self.robot = os.popen("ls /dev/ttyUSB*") + if "dev" in self.robot: + self.Pin = [2,5] + else: + self.Pin = [20,21] + for i in self.move_coords: + i[2] -= 20 + + # choose place to set cube + self.color = 0 + # parameters to calculate camera clipping parameters + self.x1 = self.x2 = self.y1 = self.y2 =0 + # set cache of real coord + self.cache_x = self.cache_y = 0 + # load model of img recognition + #self.model_path = os.path.join(dir_path, "frozen_inference_graph.pb") + #self.pbtxt_path = os.path.join(dir_path, "graph.pbtxt") + #self.label_path = os.path.join(dir_path, "labels.json") + # load class labels + # self.labels = json.load(open(self.label_path)) + # use to calculate coord between cube and mycobot + self.sum_x1= self.sum_x2= self.sum_y2= self.sum_y1= 0 + # The coordinates of the grab center point relative to the mycobot + self.camera_x, self.camera_y = camera_x, camera_y + # The coordinates of the cube relative to the mycobot + self.c_x, self.c_y = 0,0 + # The ratio of pixels to actual values + self.ratio = 0 + # Get ArUco marker dict that can be detected. + self.aruco_dict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_6X6_250) + # Get ArUco marker params. + self.aruco_params = cv2.aruco.DetectorParameters_create() + + # if IS_CV_4: + # self.net = cv2.dnn.readNetFromTensorflow(self.model_path, self.pbtxt_path) + # else: + # print('Load tensorflow model need the version of opencv is 4.') + # exit(0) + # init a node and a publisher + rospy.init_node("marker", anonymous=True) + self.pub = rospy.Publisher('/cube', Marker, queue_size=1) + # init a Marker + self.marker = Marker() + self.marker.header.frame_id = "/joint1" + self.marker.ns = "cube" + self.marker.type = self.marker.CUBE + self.marker.action = self.marker.ADD + self.marker.scale.x = 0.04 + self.marker.scale.y = 0.04 + self.marker.scale.z = 0.04 + self.marker.color.a = 1.0 + self.marker.color.g = 1.0 + self.marker.color.r = 1.0 + + + # marker position initial + self.marker.pose.position.x = 0 + self.marker.pose.position.y = 0 + self.marker.pose.position.z = 0.03 + self.marker.pose.orientation.x = 0 + self.marker.pose.orientation.y = 0 + self.marker.pose.orientation.z = 0 + self.marker.pose.orientation.w = 1.0 + + self.cache_x = self.cache_y = 0 + # publish marker + def pub_marker(self, x, y , z=0.03): + self.marker.header.stamp = rospy.Time.now() + self.marker.pose.position.x = x + self.marker.pose.position.y = y + self.marker.pose.position.z = z + self.marker.color.g = self.color + self.pub.publish(self.marker) + + # Grasping motion + def move(self, x,y,color): + # send Angle to move mycobot + self.pub_angles(self.move_angles[0], 20) + time.sleep(1.5) + self.pub_angles(self.move_angles[1], 20) + time.sleep(1.5) + self.pub_angles(self.move_angles[2], 20) + time.sleep(1.5) + # send coordinates to move mycobot + self.pub_coords([x, y, 165, -178.9, -1.57, -25.95], 20, 1) + time.sleep(1.5) + + if "dev" in self.robot: + self.pub_coords([x, y, 90, -178.9, -1.57, -25.95], 20, 1) + else: + + h = 0 + if 165180: + h = 20 + elif x<135: + h = -20 + #print 'down_1:',[x, y, 31.9+h, -178.9, -1, -25.95] + self.pub_coords([x, y, 31.9+h, -178.9, -1, -25.95], 20, 1) + time.sleep(1.5) + # open pump + self.pub_pump(True,self.Pin) + time.sleep(0.5) + self.pub_angles(self.move_angles[2], 20) + time.sleep(3) + self.pub_marker(self.move_coords[2][0]/1000.0, self.move_coords[2][1]/1000.0, self.move_coords[2][2]/1000.0) + + self.pub_angles(self.move_angles[1], 20) + time.sleep(1.5) + self.pub_marker(self.move_coords[3][0]/1000.0, self.move_coords[3][1]/1000.0, self.move_coords[3][2]/1000.0) + + self.pub_angles(self.move_angles[0], 20) + time.sleep(1.5) + self.pub_marker(self.move_coords[4][0]/1000.0, self.move_coords[4][1]/1000.0, self.move_coords[4][2]/1000.0) + + self.pub_coords(self.move_coords[color], 20, 1) + self.pub_marker(self.move_coords[color][0]/1000.0, self.move_coords[color][1]/1000.0, self.move_coords[color][2]/1000.0) + time.sleep(2) + # close pump + self.pub_pump(False,self. +Pin) + if color==1: + self.pub_marker(self.move_coords[color][0]/1000.0+0.04, self.move_coords[color][1]/1000.0-0.02) + elif color==0: + self.pub_marker(self.move_coords[color][0]/1000.0+0.03, self.move_coords[color][1]/1000.0) + self.pub_angles(self.move_angles[0], 20) + time.sleep(3) + + + # decide whether grab cube + def decide_move(self, x, y, color): + print(x, y,self.cache_x, self.cache_y) + # detect the cube status move or run + if (abs(x - self.cache_x) + abs(y - self.cache_y)) / 2 > 5: # mm + self.cache_x, self.cache_y = x, y + return + else: + self.cache_x = self.cache_y = 0 + if "dev" not in self.robot: + if (y<-30 and x>140) or (x>150 and y<-10): + x -= 10 + y += 10 + elif y>-10: + y += 10 + elif x>170: + x -=10 + y +=10 + #print x,y + self.move(x,y,color) + + # init mycobot + def run(self): + for _ in range(5): + self.pub_angles([-7.11, -6.94, -55.01, -24.16, 0, -38.84], 20) + print(_) + time.sleep(0.5) + self.pub_pump(False,self.Pin) + + # draw aruco + def draw_marker(self,img,x,y): + # draw rectangle on img + cv2.rectangle( + img, + (x - 20, y - 20), + (x + 20, y + 20), + (0, 255, 0), + thickness=2, + lineType=cv2.FONT_HERSHEY_COMPLEX, + ) + # add text on rectangle + cv2.putText(img,"({},{})".format(x,y),(x,y),cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (243, 0, 0), 2,) + + # get points of two aruco + def get_calculate_params(self,img): + # Convert the image to a gray image + gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + # Detect ArUco marker. + corners, ids, rejectImaPoint = cv2.aruco.detectMarkers( + gray, self.aruco_dict, parameters=self.aruco_params + ) + + """ + Two Arucos must be present in the picture and in the same order. + There are two Arucos in the Corners, and each aruco contains the pixels of its four corners. + Determine the center of the aruco by the four corners of the aruco. + """ + if len(corners) > 0: + if ids is not None: + if len(corners) <= 1 or ids[0]==1: + return None + x1=x2=y1=y2 = 0 + point_11,point_21,point_31,point_41 = corners[0][0] + x1, y1 = int((point_11[0] + point_21[0] + point_31[0] + point_41[0]) / 4.0), int((point_11[1] + point_21[1] + point_31[1] + point_41[1]) / 4.0) + point_1,point_2,point_3,point_4 = corners[1][0] + x2, y2 = int((point_1[0] + point_2[0] + point_3[0] + point_4[0]) / 4.0), int((point_1[1] + point_2[1] + point_3[1] + point_4[1]) / 4.0) + return x1,x2,y1,y2 + return None + + # set camera clipping parameters + def set_cut_params(self, x1, y1, x2, y2): + self.x1 = int(x1) + self.y1 = int(y1) + self.x2 = int(x2) + self.y2 = int(y2) + print(self.x1,self.y1,self.x2,self.y2) + + # set parameters to calculate the coords between cube and mycobot + def set_params(self, c_x, c_y, ratio): + self.c_x = c_x + self.c_y = c_y + self.ratio = 220.0/ratio + + # calculate the coords between cube and mycobot + def get_position(self, x, y): + return ((y - self.c_y)*self.ratio + self.camera_x), ((x - self.c_x)*self.ratio + self.camera_y) + + """ + Calibrate the camera according to the calibration parameters. + Enlarge the video pixel by 1.5 times, which means enlarge the video size by 1.5 times. + If two ARuco values have been calculated, clip the video. + """ + def transform_frame(self, frame): + # enlarge the image by 1.5 times + fx = 1.5 + fy = 1.5 + frame = cv2.resize(frame, (0, 0), fx=fx, fy=fy, interpolation=cv2.INTER_CUBIC) + if self.x1 != self.x2: + # the cutting ratio here is adjusted according to the actual situation + frame = frame[int(self.y2*0.2):int(self.y1*1.15), int(self.x1*0.7):int(self.x2*1.15)] + return frame + + # according the class_id to get object name + def id_class_name(self, class_id): + for key, value in self.labels.items(): + if class_id == int(key): + return value + + + # detect object + def obj_detect(self, img, goal): + # rows, cols = frame.shape[:-1] + # Resize image and swap BGR to RGB. + # blob = cv2.dnn.blobFromImage( + # frame, + # size=(300, 300), + # mean=(0, 0, 0), + # swapRB=True, + # crop=False, + # ) + + # Detecting. + # self.net.setInput(blob) + # out = self.net.forward() + # x, y = 0, 0 + + # Processing result. + # for detection in out[0, 0, :, :]: + # score = float(detection[2]) + # if score > 0.3: + # class_id = detection[1] + # left = detection[3] * cols + # top = detection[4] * rows + # right = detection[5] * cols + # bottom = detection[6] * rows + # if abs(right + bottom - left - top) > 380: + # continue + # x, y = (left + right) / 2.0, (top + bottom) / 2.0 + # cv2.rectangle( + # frame, + # (int(left), int(top)), + # (int(right), int(bottom)), + # (0, 230, 0), + # thickness=2, + # ) + # cv2.putText( + # frame, + # "{}: {}%".format(self.id_class_name(class_id),round(score * 100, 2)), + # (int(left), int(top) - 10), + # cv2.FONT_HERSHEY_COMPLEX_SMALL, + # 1, + # (243, 0, 0), + # 2, + # ) + i = 0 + MIN_MATCH_COUNT = 10 + sift = cv2.xfeatures2d.SIFT_create() + + # find the keypoints and descriptors with SIFT + kp = [] + des = [] + + for i in goal: + kp0,des0 = sift.detectAndCompute(i, None) + kp.append(kp0) + des.append(des0) + # kp1, des1 = sift.detectAndCompute(goal, None) + kp2, des2 = sift.detectAndCompute(img, None) + + # FLANN parameters + FLANN_INDEX_KDTREE = 0 + index_params = dict(algorithm=FLANN_INDEX_KDTREE, trees=5) + search_params = dict(checks=50) # or pass empty dictionary + flann = cv2.FlannBasedMatcher(index_params, search_params) + + x, y = 0, 0 + try: + for i in range(len(des)): + matches = flann.knnMatch(des[i], des2, k=2) + # store all the good matches as per Lowe's ratio test. 根据Lowe比率测试存储所有良好匹配项。 + good = [] + for m, n in matches: + if m.distance < 0.7*n.distance: + good.append(m) + + # When there are enough robust matching point pairs 当有足够的健壮匹配点对(至少个MIN_MATCH_COUNT)时 + if len(good) > MIN_MATCH_COUNT: + + # extract corresponding point pairs from matching 从匹配中提取出对应点对 + # query index of small objects, training index of scenarios 小对象的查询索引,场景的训练索引 + src_pts = np.float32( + [kp[i][m.queryIdx].pt for m in good]).reshape(-1, 1, 2) + dst_pts = np.float32( + [kp2[m.trainIdx].pt for m in good]).reshape(-1, 1, 2) + + # Using matching points to find homography matrix in cv2.ransac 利用匹配点找到CV2.RANSAC中的单应矩阵 + M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC, 5.0) + matchesMask = mask.ravel().tolist() + # Calculate the distortion of image, that is the corresponding position in frame 计算图1的畸变,也就是在图2中的对应的位置 + h, w, d = goal[i].shape + pts = np.float32( + [[0, 0], [0, h-1], [w-1, h-1], [w-1, 0]]).reshape(-1, 1, 2) + dst = cv2.perspectiveTransform(pts, M) + ccoord = (dst[0][0]+dst[1][0]+dst[2][0]+dst[3][0])/4.0 + cv2.putText(img, "{}".format(ccoord), (50, 60), fontFace=None, + fontScale=1, color=(0, 255, 0), lineType=1) + print(format(dst[0][0][0])) + x = (dst[0][0][0]+dst[1][0][0]+dst[2][0][0]+dst[3][0][0])/4.0 + y = (dst[0][0][1]+dst[1][0][1]+dst[2][0][1]+dst[3][0][1])/4.0 + + # bound box 绘制边框 + img = cv2.polylines( + img, [np.int32(dst)], True, 244, 3, cv2.LINE_AA) + # cv2.polylines(mixture, [np.int32(dst)], True, (0, 255, 0), 2, cv2.LINE_AA) + except Exception as e: + pass + + else: + if(len(good) < MIN_MATCH_COUNT): + + i += 1 + if(i % 10 == 0): + print("Not enough matches are found - %d/%d" % + (len(good), MIN_MATCH_COUNT)) + + matchesMask = None + if x+y > 0: + return x, y + else: + return None + def take_photo(self): + # 提醒用户操作字典 + print("*********************************************") + print("* 热键(请在摄像头的窗口使用): *") + print("* z: 拍摄图片 *") + print("* q: 退出 *") + print("*********************************************") + + # 创建/使用local_photo文件夹 + class_name = "local_photo" + if(os.path.exists("local_photo")): + pass + else: + os.mkdir(class_name) + + # 设置特定值 + + index = 'takephoto' + cap = cv2.VideoCapture(0) + + while True: + # 读入每一帧 + ret, frame = cap.read() + + cv2.imshow("capture", frame) + + # 存储 + input = cv2.waitKey(1) & 0xFF + # 拍照 + if input == ord('z'): + cv2.imwrite("%s/%s.jpeg" % (class_name, index), + cv2.resize(frame, (600, 480), interpolation=cv2.INTER_AREA)) + break + + # 退出 + if input == ord('q'): + break + + # 关闭窗口 + cap.release() + cv2.destroyAllWindows() + + def cut_photo(self): + path = os.getcwd()+'/local_photo/img' + print path + for i,j,k in os.walk(path): + file_len = len(k) + print("请截取要识别的部分") + # root = tk.Tk() + # root.withdraw() + # temp1=filedialog.askopenfilename(parent=root) #rgb + # temp2=Image.open(temp1,mode='r') + # temp2= cv.cvtColor(np.asarray(temp2),cv.COLOR_RGB2BGR) + # cut = np.array(temp2) + + cut = cv2.imread(r"local_photo/takephoto.jpeg") + + cv2.imshow('original', cut) + # C:\Users\Elephant\Desktop\pymycobot+opencv\local_photo/takephoto.jpeg + + # 选择ROI + roi = cv2.selectROI(windowName="original", img=cut, + showCrosshair=False, fromCenter=False) + x, y, w, h = roi + print(roi) + + # 显示ROI并保存图片 + if roi != (0, 0, 0, 0): + crop = cut[y:y+h, x:x+w] + cv2.imshow('crop', crop) + cv2.imwrite('local_photo/img/goal{}.jpeg'.format(str(file_len+1)), crop) + print('Saved!') + + # 退出 + cv2.waitKey(0) + cv2.destroyAllWindows() + + def distinguist(self): + print("请选择要识别的物体图片") + root = tk.Tk() # 显式创建根窗体 + root.withdraw() # 将根窗体隐藏 + file = filedialog.askopenfilename(parent=root) + load = Image.open(file, mode='r') + load = cv.cvtColor(np.asarray(load), cv.COLOR_RGB2BGR) + goal = np.array(load) + return goal + + +def run(stop): + + #Object_detect().take_photo() + #Object_detect().cut_photo() + # goal = Object_detect().distinguist() + goal = [] + path = os.getcwd()+'/local_photo/img' + print path + for i,j,k in os.walk(path): + for l in k: + goal.append(cv2.imread('local_photo/img/{}'.format(l))) + cap_num = 0 + cap = cv2.VideoCapture(cap_num) + if not cap.isOpened(): + cap.open() + # init a class of Object_detect + detect = Object_detect() + # init mycobot + detect.run() + + _init_ = 20 # + init_num = 0 + nparams = 0 + num = 0 + real_sx = real_sy = 0 + while cv2.waitKey(1) < 0: + # read camera + _,frame = cap.read() + # deal img + frame = detect.transform_frame(frame) + + + if _init_ > 0: + _init_-=1 + continue + # calculate the parameters of camera clipping + if init_num < 20: + if detect.get_calculate_params(frame) is None: + cv2.imshow("figure",frame) + continue + else: + x1,x2,y1,y2 = detect.get_calculate_params(frame) + detect.draw_marker(frame,x1,y1) + detect.draw_marker(frame,x2,y2) + detect.sum_x1+=x1 + detect.sum_x2+=x2 + detect.sum_y1+=y1 + detect.sum_y2+=y2 + init_num+=1 + continue + elif init_num==20: + detect.set_cut_params( + (detect.sum_x1)/20.0, + (detect.sum_y1)/20.0, + (detect.sum_x2)/20.0, + (detect.sum_y2)/20.0, + ) + detect.sum_x1 = detect.sum_x2 = detect.sum_y1 = detect.sum_y2 = 0 + init_num+=1 + continue + + # calculate params of the coords between cube and mycobot + if nparams < 10: + if detect.get_calculate_params(frame) is None: + cv2.imshow("figure",frame) + continue + else: + x1,x2,y1,y2 = detect.get_calculate_params(frame) + detect.draw_marker(frame,x1,y1) + detect.draw_marker(frame,x2,y2) + detect.sum_x1+=x1 + detect.sum_x2+=x2 + detect.sum_y1+=y1 + detect.sum_y2+=y2 + nparams+=1 + continue + elif nparams==10: + nparams+=1 + # calculate and set params of calculating real coord between cube and mycobot + detect.set_params( + (detect.sum_x1+detect.sum_x2)/20.0, + (detect.sum_y1+detect.sum_y2)/20.0, + abs(detect.sum_x1-detect.sum_x2)/10.0+abs(detect.sum_y1-detect.sum_y2)/10.0 + ) + print "ok" + continue + + # get detect result + detect_result = detect.obj_detect(frame,goal) + if detect_result is None: + cv2.imshow("figure",frame) + continue + else: + x, y = detect_result + # calculate real coord between cube and mycobot + real_x, real_y = detect.get_position(x, y) + if num == 5: + detect.pub_marker(real_sx/5.0/1000.0, real_sy/5.0/1000.0) + detect.decide_move(real_sx/5.0, real_sy/5.0, detect.color) + num = real_sx = real_sy = 0 + + else: + num += 1 + real_sy += real_y + real_sx += real_x + + cv2.imshow("figure",frame) + + +if __name__ == "__main__": + run(0) + #Object_detect().take_photo() + #Object_detect().cut_photo() + diff --git a/mycobot_ai/scripts/frozen_inference_graph.pb b/mycobot_ai/scripts/frozen_inference_graph.pb new file mode 100644 index 0000000..92189ed Binary files /dev/null and b/mycobot_ai/scripts/frozen_inference_graph.pb differ diff --git a/mycobot_ai/scripts/graph.pbtxt b/mycobot_ai/scripts/graph.pbtxt new file mode 100644 index 0000000..9791f03 --- /dev/null +++ b/mycobot_ai/scripts/graph.pbtxt @@ -0,0 +1,2682 @@ +node { + name: "image_tensor" + op: "Placeholder" + attr { + key: "dtype" + value { + type: DT_UINT8 + } + } + attr { + key: "shape" + value { + shape { + dim { + size: -1 + } + dim { + size: 300 + } + dim { + size: 300 + } + dim { + size: 3 + } + } + } + } +} +node { + name: "Preprocessor/mul" + op: "Mul" + input: "image_tensor" + input: "Preprocessor/mul/x" +} +node { + name: "Preprocessor/sub" + op: "Sub" + input: "Preprocessor/mul" + input: "Preprocessor/sub/y" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "Preprocessor/sub" + input: "FeatureExtractor/MobilenetV1/Conv2d_0/weights/read/_104__cf__107" + input: "^FeatureExtractor/Assert/Assert" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 2 + i: 2 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/sub/_103__cf__106" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_1_depthwise/depthwise_weights/read/_101__cf__104" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/BatchNorm/batchnorm/mul/_99__cf__102" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/BatchNorm/batchnorm/sub/_100__cf__103" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_1_pointwise/weights/read/_98__cf__101" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_pointwise/BatchNorm/batchnorm/sub/_97__cf__100" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_2_depthwise/depthwise_weights/read/_95__cf__98" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 2 + i: 2 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_depthwise/BatchNorm/batchnorm/mul/_93__cf__96" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_depthwise/BatchNorm/batchnorm/sub/_94__cf__97" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_2_pointwise/weights/read/_92__cf__95" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_pointwise/BatchNorm/batchnorm/sub/_91__cf__94" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_2_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_3_depthwise/depthwise_weights/read/_89__cf__92" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_depthwise/BatchNorm/batchnorm/mul/_87__cf__90" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_depthwise/BatchNorm/batchnorm/sub/_88__cf__91" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_3_pointwise/weights/read/_86__cf__89" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_pointwise/BatchNorm/batchnorm/sub/_85__cf__88" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_3_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_4_depthwise/depthwise_weights/read/_83__cf__86" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 2 + i: 2 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_depthwise/BatchNorm/batchnorm/mul/_81__cf__84" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_depthwise/BatchNorm/batchnorm/sub/_82__cf__85" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_4_pointwise/weights/read/_80__cf__83" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_pointwise/BatchNorm/batchnorm/sub/_79__cf__82" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_4_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_5_depthwise/depthwise_weights/read/_77__cf__80" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_depthwise/BatchNorm/batchnorm/mul/_75__cf__78" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_depthwise/BatchNorm/batchnorm/sub/_76__cf__79" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_5_pointwise/weights/read/_74__cf__77" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_pointwise/BatchNorm/batchnorm/sub/_73__cf__76" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_5_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_6_depthwise/depthwise_weights/read/_71__cf__74" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 2 + i: 2 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_depthwise/BatchNorm/batchnorm/mul/_69__cf__72" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_depthwise/BatchNorm/batchnorm/sub/_70__cf__73" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_6_pointwise/weights/read/_68__cf__71" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_pointwise/BatchNorm/batchnorm/sub/_67__cf__70" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_6_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_7_depthwise/depthwise_weights/read/_65__cf__68" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_depthwise/BatchNorm/batchnorm/mul/_63__cf__66" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_depthwise/BatchNorm/batchnorm/sub/_64__cf__67" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_7_pointwise/weights/read/_62__cf__65" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_pointwise/BatchNorm/batchnorm/sub/_61__cf__64" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_7_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_8_depthwise/depthwise_weights/read/_59__cf__62" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_depthwise/BatchNorm/batchnorm/mul/_57__cf__60" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_depthwise/BatchNorm/batchnorm/sub/_58__cf__61" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_8_pointwise/weights/read/_56__cf__59" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_pointwise/BatchNorm/batchnorm/sub/_55__cf__58" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_8_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_9_depthwise/depthwise_weights/read/_53__cf__56" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_depthwise/BatchNorm/batchnorm/mul/_51__cf__54" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_depthwise/BatchNorm/batchnorm/sub/_52__cf__55" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_9_pointwise/weights/read/_50__cf__53" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_pointwise/BatchNorm/batchnorm/sub/_49__cf__52" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_9_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_10_depthwise/depthwise_weights/read/_47__cf__50" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_depthwise/BatchNorm/batchnorm/mul/_45__cf__48" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_depthwise/BatchNorm/batchnorm/sub/_46__cf__49" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_10_pointwise/weights/read/_44__cf__47" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_pointwise/BatchNorm/batchnorm/sub/_43__cf__46" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_10_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_11_depthwise/depthwise_weights/read/_41__cf__44" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_depthwise/BatchNorm/batchnorm/mul/_39__cf__42" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_depthwise/BatchNorm/batchnorm/sub/_40__cf__43" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_11_pointwise/weights/read/_38__cf__41" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_pointwise/BatchNorm/batchnorm/sub/_37__cf__40" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "BoxPredictor_0/ClassPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_pointwise/Relu6" + input: "BoxPredictor_0/ClassPredictor/weights/read/_178__cf__181" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_0/ClassPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_0/ClassPredictor/Conv2D" + input: "BoxPredictor_0/ClassPredictor/biases/read/_177__cf__180" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "BoxPredictor_0/BoxEncodingPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_pointwise/Relu6" + input: "BoxPredictor_0/BoxEncodingPredictor/weights/read/_116__cf__119" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "loc_pred_transposed" + value { + b: true + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_0/BoxEncodingPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_0/BoxEncodingPredictor/Conv2D" + input: "BoxPredictor_0/BoxEncodingPredictor/biases/read/_115__cf__118" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_11_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_12_depthwise/depthwise_weights/read/_35__cf__38" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 2 + i: 2 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_depthwise/BatchNorm/batchnorm/mul/_33__cf__36" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_depthwise/BatchNorm/batchnorm/sub/_34__cf__37" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_12_pointwise/weights/read/_32__cf__35" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_pointwise/BatchNorm/batchnorm/sub/_31__cf__34" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_depthwise/depthwise" + op: "DepthwiseConv2dNative" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_12_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_depthwise/depthwise_weights/read/_29__cf__32" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_depthwise/BatchNorm/batchnorm/mul_1" + op: "Mul" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_depthwise/depthwise" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_depthwise/BatchNorm/batchnorm/mul/_27__cf__30" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_depthwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_depthwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_depthwise/BatchNorm/batchnorm/sub/_28__cf__31" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_depthwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_depthwise/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_pointwise/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_depthwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise/weights/read/_26__cf__29" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_pointwise/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_pointwise/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_pointwise/BatchNorm/batchnorm/sub/_25__cf__28" +} +node { + name: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_pointwise/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_pointwise/BatchNorm/batchnorm/add_1" +} +node { + name: "BoxPredictor_1/ClassPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_pointwise/Relu6" + input: "BoxPredictor_1/ClassPredictor/weights/read/_176__cf__179" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_1/ClassPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_1/ClassPredictor/Conv2D" + input: "BoxPredictor_1/ClassPredictor/biases/read/_175__cf__178" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "BoxPredictor_1/BoxEncodingPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_pointwise/Relu6" + input: "BoxPredictor_1/BoxEncodingPredictor/weights/read/_114__cf__117" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "loc_pred_transposed" + value { + b: true + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_1/BoxEncodingPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_1/BoxEncodingPredictor/Conv2D" + input: "BoxPredictor_1/BoxEncodingPredictor/biases/read/_113__cf__116" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_2_1x1_256/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_13_pointwise/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_2_1x1_256/weights/read/_23__cf__26" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_2_1x1_256/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_2_1x1_256/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_2_1x1_256/BatchNorm/batchnorm/sub/_22__cf__25" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_2_1x1_256/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_2_1x1_256/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_2_3x3_s2_512/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_2_1x1_256/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_2_3x3_s2_512/weights/read/_20__cf__23" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 2 + i: 2 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_2_3x3_s2_512/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_2_3x3_s2_512/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_2_3x3_s2_512/BatchNorm/batchnorm/sub/_19__cf__22" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_2_3x3_s2_512/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_2_3x3_s2_512/BatchNorm/batchnorm/add_1" +} +node { + name: "BoxPredictor_2/ClassPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_2_3x3_s2_512/Relu6" + input: "BoxPredictor_2/ClassPredictor/weights/read/_174__cf__177" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_2/ClassPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_2/ClassPredictor/Conv2D" + input: "BoxPredictor_2/ClassPredictor/biases/read/_173__cf__176" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "BoxPredictor_2/BoxEncodingPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_2_3x3_s2_512/Relu6" + input: "BoxPredictor_2/BoxEncodingPredictor/weights/read/_112__cf__115" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "loc_pred_transposed" + value { + b: true + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_2/BoxEncodingPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_2/BoxEncodingPredictor/Conv2D" + input: "BoxPredictor_2/BoxEncodingPredictor/biases/read/_111__cf__114" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_3_1x1_128/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_2_3x3_s2_512/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_3_1x1_128/weights/read/_17__cf__20" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_3_1x1_128/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_3_1x1_128/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_3_1x1_128/BatchNorm/batchnorm/sub/_16__cf__19" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_3_1x1_128/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_3_1x1_128/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_3_3x3_s2_256/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_3_1x1_128/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_3_3x3_s2_256/weights/read/_14__cf__17" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 2 + i: 2 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_3_3x3_s2_256/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_3_3x3_s2_256/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_3_3x3_s2_256/BatchNorm/batchnorm/sub/_13__cf__16" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_3_3x3_s2_256/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_3_3x3_s2_256/BatchNorm/batchnorm/add_1" +} +node { + name: "BoxPredictor_3/ClassPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_3_3x3_s2_256/Relu6" + input: "BoxPredictor_3/ClassPredictor/weights/read/_172__cf__175" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_3/ClassPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_3/ClassPredictor/Conv2D" + input: "BoxPredictor_3/ClassPredictor/biases/read/_171__cf__174" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "BoxPredictor_3/BoxEncodingPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_3_3x3_s2_256/Relu6" + input: "BoxPredictor_3/BoxEncodingPredictor/weights/read/_110__cf__113" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "loc_pred_transposed" + value { + b: true + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_3/BoxEncodingPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_3/BoxEncodingPredictor/Conv2D" + input: "BoxPredictor_3/BoxEncodingPredictor/biases/read/_109__cf__112" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_4_1x1_128/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_3_3x3_s2_256/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_4_1x1_128/weights/read/_11__cf__14" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_4_1x1_128/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_4_1x1_128/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_4_1x1_128/BatchNorm/batchnorm/sub/_10__cf__13" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_4_1x1_128/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_4_1x1_128/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_4_3x3_s2_256/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_4_1x1_128/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_4_3x3_s2_256/weights/read/_8__cf__11" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 2 + i: 2 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_4_3x3_s2_256/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_4_3x3_s2_256/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_4_3x3_s2_256/BatchNorm/batchnorm/sub/_7__cf__10" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_4_3x3_s2_256/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_4_3x3_s2_256/BatchNorm/batchnorm/add_1" +} +node { + name: "BoxPredictor_4/ClassPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_4_3x3_s2_256/Relu6" + input: "BoxPredictor_4/ClassPredictor/weights/read/_170__cf__173" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_4/ClassPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_4/ClassPredictor/Conv2D" + input: "BoxPredictor_4/ClassPredictor/biases/read/_169__cf__172" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "BoxPredictor_4/BoxEncodingPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_4_3x3_s2_256/Relu6" + input: "BoxPredictor_4/BoxEncodingPredictor/weights/read/_108__cf__111" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "loc_pred_transposed" + value { + b: true + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_4/BoxEncodingPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_4/BoxEncodingPredictor/Conv2D" + input: "BoxPredictor_4/BoxEncodingPredictor/biases/read/_107__cf__110" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_5_1x1_64/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_4_3x3_s2_256/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_5_1x1_64/weights/read/_5__cf__8" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_5_1x1_64/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_5_1x1_64/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_5_1x1_64/BatchNorm/batchnorm/sub/_4__cf__7" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_5_1x1_64/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_5_1x1_64/BatchNorm/batchnorm/add_1" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_5_3x3_s2_128/BatchNorm/batchnorm/mul_1" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_1_Conv2d_5_1x1_64/Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_5_3x3_s2_128/weights/read/_2__cf__5" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 2 + i: 2 + i: 1 + } + } + } +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_5_3x3_s2_128/BatchNorm/batchnorm/add_1" + op: "Add" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_5_3x3_s2_128/BatchNorm/batchnorm/mul_1" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_5_3x3_s2_128/BatchNorm/batchnorm/sub/_1__cf__4" +} +node { + name: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_5_3x3_s2_128/Relu6" + op: "Relu6" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_5_3x3_s2_128/BatchNorm/batchnorm/add_1" +} +node { + name: "BoxPredictor_5/ClassPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_5_3x3_s2_128/Relu6" + input: "BoxPredictor_5/ClassPredictor/weights/read/_168__cf__171" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_5/ClassPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_5/ClassPredictor/Conv2D" + input: "BoxPredictor_5/ClassPredictor/biases/read/_167__cf__170" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "BoxPredictor_5/BoxEncodingPredictor/Conv2D" + op: "Conv2D" + input: "FeatureExtractor/MobilenetV1/Conv2d_13_pointwise_2_Conv2d_5_3x3_s2_128/Relu6" + input: "BoxPredictor_5/BoxEncodingPredictor/weights/read/_106__cf__109" + attr { + key: "data_format" + value { + s: "NHWC" + } + } + attr { + key: "loc_pred_transposed" + value { + b: true + } + } + attr { + key: "padding" + value { + s: "SAME" + } + } + attr { + key: "strides" + value { + list { + i: 1 + i: 1 + i: 1 + i: 1 + } + } + } +} +node { + name: "BoxPredictor_5/BoxEncodingPredictor/BiasAdd" + op: "BiasAdd" + input: "BoxPredictor_5/BoxEncodingPredictor/Conv2D" + input: "BoxPredictor_5/BoxEncodingPredictor/biases/read/_105__cf__108" + attr { + key: "data_format" + value { + s: "NHWC" + } + } +} +node { + name: "concat/axis_flatten" + op: "Const" + attr { + key: "value" + value { + tensor { + dtype: DT_INT32 + int_val: -1 + tensor_shape { + dim { + size: 1 + } + } + } + } + } +} +node { + name: "BoxPredictor_0/ClassPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_0/ClassPredictor/BiasAdd" +} +node { + name: "BoxPredictor_1/ClassPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_1/ClassPredictor/BiasAdd" +} +node { + name: "BoxPredictor_2/ClassPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_2/ClassPredictor/BiasAdd" +} +node { + name: "BoxPredictor_3/ClassPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_3/ClassPredictor/BiasAdd" +} +node { + name: "BoxPredictor_4/ClassPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_4/ClassPredictor/BiasAdd" +} +node { + name: "BoxPredictor_5/ClassPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_5/ClassPredictor/BiasAdd" +} +node { + name: "ClassPredictor/concat" + op: "ConcatV2" + input: "BoxPredictor_0/ClassPredictor/BiasAdd/Flatten" + input: "BoxPredictor_1/ClassPredictor/BiasAdd/Flatten" + input: "BoxPredictor_2/ClassPredictor/BiasAdd/Flatten" + input: "BoxPredictor_3/ClassPredictor/BiasAdd/Flatten" + input: "BoxPredictor_4/ClassPredictor/BiasAdd/Flatten" + input: "BoxPredictor_5/ClassPredictor/BiasAdd/Flatten" + input: "concat/axis_flatten" +} +node { + name: "BoxPredictor_0/BoxEncodingPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_0/BoxEncodingPredictor/BiasAdd" +} +node { + name: "BoxPredictor_1/BoxEncodingPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_1/BoxEncodingPredictor/BiasAdd" +} +node { + name: "BoxPredictor_2/BoxEncodingPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_2/BoxEncodingPredictor/BiasAdd" +} +node { + name: "BoxPredictor_3/BoxEncodingPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_3/BoxEncodingPredictor/BiasAdd" +} +node { + name: "BoxPredictor_4/BoxEncodingPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_4/BoxEncodingPredictor/BiasAdd" +} +node { + name: "BoxPredictor_5/BoxEncodingPredictor/BiasAdd/Flatten" + op: "Flatten" + input: "BoxPredictor_5/BoxEncodingPredictor/BiasAdd" +} +node { + name: "BoxEncodingPredictor/concat" + op: "ConcatV2" + input: "BoxPredictor_0/BoxEncodingPredictor/BiasAdd/Flatten" + input: "BoxPredictor_1/BoxEncodingPredictor/BiasAdd/Flatten" + input: "BoxPredictor_2/BoxEncodingPredictor/BiasAdd/Flatten" + input: "BoxPredictor_3/BoxEncodingPredictor/BiasAdd/Flatten" + input: "BoxPredictor_4/BoxEncodingPredictor/BiasAdd/Flatten" + input: "BoxPredictor_5/BoxEncodingPredictor/BiasAdd/Flatten" + input: "concat/axis_flatten" +} +node { + name: "PriorBox_0" + op: "PriorBox" + input: "BoxPredictor_0/BoxEncodingPredictor/BiasAdd" + input: "image_tensor" + attr { + key: "clip" + value { + b: false + } + } + attr { + key: "flip" + value { + b: false + } + } + attr { + key: "height" + value { + tensor { + dtype: DT_FLOAT + float_val: 30.0 + float_val: 42.42640687119285 + float_val: 84.8528137423857 + tensor_shape { + dim { + size: 3 + } + } + } + } + } + attr { + key: "variance" + value { + tensor { + dtype: DT_FLOAT + float_val: 0.1 + float_val: 0.1 + float_val: 0.2 + float_val: 0.2 + tensor_shape { + dim { + size: 4 + } + } + } + } + } + attr { + key: "width" + value { + tensor { + dtype: DT_FLOAT + float_val: 30.0 + float_val: 84.85281374238572 + float_val: 42.42640687119286 + tensor_shape { + dim { + size: 3 + } + } + } + } + } +} +node { + name: "PriorBox_1" + op: "PriorBox" + input: "BoxPredictor_1/BoxEncodingPredictor/BiasAdd" + input: "image_tensor" + attr { + key: "clip" + value { + b: false + } + } + attr { + key: "flip" + value { + b: false + } + } + attr { + key: "height" + value { + tensor { + dtype: DT_FLOAT + float_val: 105.0 + float_val: 74.24621202458748 + float_val: 148.49242404917496 + float_val: 60.62177826491071 + float_val: 181.87442874352365 + float_val: 125.49900398011134 + tensor_shape { + dim { + size: 6 + } + } + } + } + } + attr { + key: "variance" + value { + tensor { + dtype: DT_FLOAT + float_val: 0.1 + float_val: 0.1 + float_val: 0.2 + float_val: 0.2 + tensor_shape { + dim { + size: 4 + } + } + } + } + } + attr { + key: "width" + value { + tensor { + dtype: DT_FLOAT + float_val: 105.0 + float_val: 148.49242404917499 + float_val: 74.24621202458749 + float_val: 181.8653347947321 + float_val: 60.618747100216446 + float_val: 125.49900398011134 + tensor_shape { + dim { + size: 6 + } + } + } + } + } +} +node { + name: "PriorBox_2" + op: "PriorBox" + input: "BoxPredictor_2/BoxEncodingPredictor/BiasAdd" + input: "image_tensor" + attr { + key: "clip" + value { + b: false + } + } + attr { + key: "flip" + value { + b: false + } + } + attr { + key: "height" + value { + tensor { + dtype: DT_FLOAT + float_val: 150.0 + float_val: 106.06601717798212 + float_val: 212.13203435596424 + float_val: 86.60254037844388 + float_val: 259.8206124907481 + float_val: 171.0263137648707 + tensor_shape { + dim { + size: 6 + } + } + } + } + } + attr { + key: "variance" + value { + tensor { + dtype: DT_FLOAT + float_val: 0.1 + float_val: 0.1 + float_val: 0.2 + float_val: 0.2 + tensor_shape { + dim { + size: 4 + } + } + } + } + } + attr { + key: "width" + value { + tensor { + dtype: DT_FLOAT + float_val: 150.0 + float_val: 212.13203435596427 + float_val: 106.06601717798213 + float_val: 259.8076211353316 + float_val: 86.59821014316636 + float_val: 171.0263137648707 + tensor_shape { + dim { + size: 6 + } + } + } + } + } +} +node { + name: "PriorBox_3" + op: "PriorBox" + input: "BoxPredictor_3/BoxEncodingPredictor/BiasAdd" + input: "image_tensor" + attr { + key: "clip" + value { + b: false + } + } + attr { + key: "flip" + value { + b: false + } + } + attr { + key: "height" + value { + tensor { + dtype: DT_FLOAT + float_val: 195.0 + float_val: 137.88582233137677 + float_val: 275.77164466275354 + float_val: 112.58330249197702 + float_val: 337.7667962379726 + float_val: 216.33307652783938 + tensor_shape { + dim { + size: 6 + } + } + } + } + } + attr { + key: "variance" + value { + tensor { + dtype: DT_FLOAT + float_val: 0.1 + float_val: 0.1 + float_val: 0.2 + float_val: 0.2 + tensor_shape { + dim { + size: 4 + } + } + } + } + } + attr { + key: "width" + value { + tensor { + dtype: DT_FLOAT + float_val: 195.0 + float_val: 275.77164466275354 + float_val: 137.88582233137677 + float_val: 337.749907475931 + float_val: 112.57767318611627 + float_val: 216.33307652783938 + tensor_shape { + dim { + size: 6 + } + } + } + } + } +} +node { + name: "PriorBox_4" + op: "PriorBox" + input: "BoxPredictor_4/BoxEncodingPredictor/BiasAdd" + input: "image_tensor" + attr { + key: "clip" + value { + b: false + } + } + attr { + key: "flip" + value { + b: false + } + } + attr { + key: "height" + value { + tensor { + dtype: DT_FLOAT + float_val: 240.0 + float_val: 169.7056274847714 + float_val: 339.4112549695428 + float_val: 138.5640646055102 + float_val: 415.71297998519697 + float_val: 261.5339366124404 + tensor_shape { + dim { + size: 6 + } + } + } + } + } + attr { + key: "variance" + value { + tensor { + dtype: DT_FLOAT + float_val: 0.1 + float_val: 0.1 + float_val: 0.2 + float_val: 0.2 + tensor_shape { + dim { + size: 4 + } + } + } + } + } + attr { + key: "width" + value { + tensor { + dtype: DT_FLOAT + float_val: 240.0 + float_val: 339.4112549695429 + float_val: 169.70562748477144 + float_val: 415.69219381653056 + float_val: 138.55713622906617 + float_val: 261.5339366124404 + tensor_shape { + dim { + size: 6 + } + } + } + } + } +} +node { + name: "PriorBox_5" + op: "PriorBox" + input: "BoxPredictor_5/BoxEncodingPredictor/BiasAdd" + input: "image_tensor" + attr { + key: "clip" + value { + b: false + } + } + attr { + key: "flip" + value { + b: false + } + } + attr { + key: "height" + value { + tensor { + dtype: DT_FLOAT + float_val: 285.0 + float_val: 201.52543263816602 + float_val: 403.05086527633205 + float_val: 164.54482671904336 + float_val: 493.6591637324214 + float_val: 292.4038303442689 + tensor_shape { + dim { + size: 6 + } + } + } + } + } + attr { + key: "variance" + value { + tensor { + dtype: DT_FLOAT + float_val: 0.1 + float_val: 0.1 + float_val: 0.2 + float_val: 0.2 + tensor_shape { + dim { + size: 4 + } + } + } + } + } + attr { + key: "width" + value { + tensor { + dtype: DT_FLOAT + float_val: 285.0 + float_val: 403.0508652763321 + float_val: 201.52543263816605 + float_val: 493.63448015713 + float_val: 164.53659927201608 + float_val: 292.4038303442689 + tensor_shape { + dim { + size: 6 + } + } + } + } + } +} +node { + name: "PriorBox/concat" + op: "ConcatV2" + input: "PriorBox_0" + input: "PriorBox_1" + input: "PriorBox_2" + input: "PriorBox_3" + input: "PriorBox_4" + input: "PriorBox_5" + input: "concat/axis_flatten" +} +node { + name: "ClassPredictor/concat3d/shape" + op: "Const" + attr { + key: "value" + value { + tensor { + dtype: DT_INT32 + int_val: 0 + int_val: -1 + int_val: 91 + tensor_shape { + dim { + size: 3 + } + } + } + } + } +} +node { + name: "ClassPredictor/concat3d" + op: "Reshape" + input: "ClassPredictor/concat" + input: "ClassPredictor/concat3d/shape" +} +node { + name: "ClassPredictor/concat/sigmoid" + op: "Sigmoid" + input: "ClassPredictor/concat3d" +} +node { + name: "ClassPredictor/concat/sigmoid/Flatten" + op: "Flatten" + input: "ClassPredictor/concat/sigmoid" +} +node { + name: "detection_out" + op: "DetectionOutput" + input: "BoxEncodingPredictor/concat" + input: "ClassPredictor/concat/sigmoid/Flatten" + input: "PriorBox/concat" + attr { + key: "background_label_id" + value { + i: 0 + } + } + attr { + key: "code_type" + value { + s: "CENTER_SIZE" + } + } + attr { + key: "confidence_threshold" + value { + f: 1e-08 + } + } + attr { + key: "keep_top_k" + value { + i: 100 + } + } + attr { + key: "nms_threshold" + value { + f: 0.6 + } + } + attr { + key: "num_classes" + value { + i: 91 + } + } + attr { + key: "share_location" + value { + b: true + } + } + attr { + key: "top_k" + value { + i: 100 + } + } +} diff --git a/mycobot_ai/scripts/labels.json b/mycobot_ai/scripts/labels.json new file mode 100644 index 0000000..c8926c6 --- /dev/null +++ b/mycobot_ai/scripts/labels.json @@ -0,0 +1,82 @@ +{ + "1": "person", + "2": "bicycle", + "3": "car", + "4": "motorcycle", + "5": "airplane", + "6": "bus", + "7": "train", + "8": "truck", + "9": "boat", + "10": "traffic light", + "11": "fire hydrant", + "13": "stop sign", + "14": "parking meter", + "15": "bench", + "16": "bird", + "17": "cat", + "18": "dog", + "19": "horse", + "20": "sheep", + "21": "cow", + "22": "elephant", + "23": "bear", + "24": "zebra", + "25": "giraffe", + "27": "backpack", + "28": "umbrella", + "31": "handbag", + "32": "tie", + "33": "suitcase", + "34": "frisbee", + "35": "skis", + "36": "snowboard", + "37": "sports ball", + "38": "kite", + "39": "baseball bat", + "40": "baseball glove", + "41": "skateboard", + "42": "surfboard", + "43": "tennis racket", + "44": "bottle", + "46": "wine glass", + "47": "cup", + "48": "fork", + "49": "knife", + "50": "spoon", + "51": "bowl", + "52": "banana", + "53": "apple", + "54": "sandwich", + "55": "orange", + "56": "broccoli", + "57": "carrot", + "58": "hot dog", + "59": "pizza", + "60": "donut", + "61": "cake", + "62": "chair", + "63": "couch", + "64": "potted plant", + "65": "bed", + "67": "dining table", + "70": "toilet", + "72": "tv", + "73": "laptop", + "74": "mouse", + "75": "remote", + "76": "keyboard", + "77": "cell phone", + "78": "microwave", + "79": "oven", + "80": "toaster", + "81": "sink", + "82": "refrigerator", + "84": "book", + "85": "clock", + "86": "vase", + "87": "scissors", + "88": "teddy bear", + "89": "hair drier", + "90": "toothbrush" +} \ No newline at end of file diff --git a/mycobot_ai/scripts/moving_utils.py b/mycobot_ai/scripts/moving_utils.py new file mode 100644 index 0000000..1b6a651 --- /dev/null +++ b/mycobot_ai/scripts/moving_utils.py @@ -0,0 +1,49 @@ +#encoding: UTF-8 +#!/usr/bin/env python2 +import rospy +import time,os + +from mycobot_communication.msg import MycobotSetAngles, MycobotSetCoords, MycobotPumpStatus + + +class Movement(object): + """Tools class: Communication with mycobot.""" + def __init__(self): + super(Movement, self).__init__() + self.angle_pub = rospy.Publisher("mycobot/angles_goal", MycobotSetAngles, queue_size=5) + self.coord_pub = rospy.Publisher("mycobot/coords_goal", MycobotSetCoords, queue_size=5) + + self.pump_pub = rospy.Publisher("mycobot/pump_status", MycobotPumpStatus, queue_size=10) + + self.angles = MycobotSetAngles() + self.coords = MycobotSetCoords() + self.pump = MycobotPumpStatus() + + def pub_coords(self, item, sp=20, m=1): + self.coords.x = item[0] + self.coords.y = item[1] + self.coords.z = item[2] + self.coords.rx = item[3] + self.coords.ry = item[4] + self.coords.rz = item[5] + self.coords.speed = sp + self.coords.model = m + self.coord_pub.publish(self.coords) + + + def pub_angles(self, item, sp): + self.angles.joint_1 = item[0] + self.angles.joint_2 = item[1] + self.angles.joint_3 = item[2] + self.angles.joint_4 = item[3] + self.angles.joint_5 = item[4] + self.angles.joint_6 = item[5] + self.angles.speed = sp + self.angle_pub.publish(self.angles) + + + def pub_pump(self, flag,Pin): + self.pump.Status = flag + self.pump.Pin1 = Pin[0] + self.pump.Pin2 = Pin[1] + self.pump_pub.publish(self.pump) diff --git a/mycobot_ai/scripts/mtx_dist.npz b/mycobot_ai/scripts/mtx_dist.npz new file mode 100644 index 0000000..88f1cee Binary files /dev/null and b/mycobot_ai/scripts/mtx_dist.npz differ diff --git a/mycobot_ai/scripts/openVideo.py b/mycobot_ai/scripts/openVideo.py new file mode 100644 index 0000000..a95db11 --- /dev/null +++ b/mycobot_ai/scripts/openVideo.py @@ -0,0 +1,8 @@ +import cv2 as cv + +if __name__ == "__main__": + cap_num = 0 + cap = cv.VideoCapture(cap_num) + while cv.waitKey(1)<0: + _, img = cap.read() + cv.imshow("", img) diff --git a/mycobot_ai/scripts/pump.py b/mycobot_ai/scripts/pump.py new file mode 100644 index 0000000..3feb6d2 --- /dev/null +++ b/mycobot_ai/scripts/pump.py @@ -0,0 +1,23 @@ +#encoding: UTF-8 +#!/usr/bin/env python2 + +import rospy +import time +from moving_utils import Movement + +class Pump(Movement): + + def __init__(self): + super(Pump, self).__init__() + rospy.init_node("pump", anonymous=True) + + def run(self): + self.pub_pump(False) + time.sleep(1) + self.pub_pump(True) + time.sleep(5) + self.pub_pump(False) + +if __name__ == "__main__": + pump = Pump() + pump.run() \ No newline at end of file diff --git a/mycobot_ai/scripts/send_maker.py b/mycobot_ai/scripts/send_maker.py new file mode 100644 index 0000000..7fb84b4 --- /dev/null +++ b/mycobot_ai/scripts/send_maker.py @@ -0,0 +1,72 @@ +# encoding: utf-8 + +import rospy +import time +from visualization_msgs.msg import Marker + +class Send_marker(object): + def __init__(self): + # 继承object类对象 + super(Send_marker, self).__init__() + # 初始化一个节点,如果没有创建节点会导致无法发布信息 + rospy.init_node("send_marker", anonymous=True) + # 创建一个发布者,用来发布marker + self.pub = rospy.Publisher("/test_marker", Marker, queue_size=1) + # 创建一个marker用来创建方块模型 + self.marker = Marker() + # 配置其所属关系,其坐标均是相对于/joint1而言的。 + # /joint1在模型中代表机械臂的底部 + self.marker.header.frame_id = "/joint1" + # 设置marker的名称 + self.marker.ns = "test_marker" + # 设置marker的类型是方块 + self.marker.type = self.marker.CUBE + # 设置marker的动作为添加(没有这个名称的marker就为其添加一个) + self.marker.action = self.marker.ADD + # 设置marker的实际大小情况,单位为m + self.marker.scale.x = 0.04 + self.marker.scale.y = 0.04 + self.marker.scale.z = 0.04 + # 设置marker的颜色,1.0表示255(这表示着一种比率换算) + self.marker.color.a = 1.0 + self.marker.color.g = 1.0 + self.marker.color.r = 1.0 + # 初始化marker的位置以及其四维姿态 + self.marker.pose.position.x = 0 + self.marker.pose.position.y = 0 + self.marker.pose.position.z = 0.03 + self.marker.pose.orientation.x = 0 + self.marker.pose.orientation.y = 0 + self.marker.pose.orientation.z = 0 + self.marker.pose.orientation.w = 1.0 + + # 修改坐标并发布marker + def pub_marker(self, x, y, z=0.03): + # 设置marker的时间戳 + self.marker.header.stamp = rospy.Time.now() + # 设置marker的空间坐标 + self.marker.pose.position.x = x + self.marker.pose.position.y = y + self.marker.pose.position.z = z + # 发布marker + self.pub.publish(self.marker) + + # 让marker发生位移效果 + def run(self): + time.sleep(1) + self.pub_marker(0.2, 0) + time.sleep(1) + self.pub_marker(0.15, -0.05) + time.sleep(1) + self.pub_marker(0.15, 0.05) + time.sleep(1) + self.pub_marker(0.1, 0) + time.sleep(1) + self.pub_marker(0.136, -0.141) + time.sleep(1) + self.pub_marker(0.238, -0.147) + time.sleep(1) + +if __name__ == '__main__': + marker = Send_marker() + marker.run() diff --git a/mycobot_ai/scripts/tools.py b/mycobot_ai/scripts/tools.py new file mode 100644 index 0000000..2e955fb --- /dev/null +++ b/mycobot_ai/scripts/tools.py @@ -0,0 +1,11 @@ +from pymycobot.mycobot import MyCobot + +# name of device +port = "/dev/ttyUSB0" +mc = MyCobot(port) + +# release mycobot +# mc.release_all_servos() + +# calibrate the sixth servo +mc.set_servo_calibration(6)