调试了模型预测的输出结果
This commit is contained in:
parent
699c0c1ff0
commit
db9e060e6f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
|
||||
/.venv/
|
||||
|
BIN
.idea/copilot/chatSessions/00000000000.xd
generated
BIN
.idea/copilot/chatSessions/00000000000.xd
generated
Binary file not shown.
7
.idea/graduation_design.iml
generated
7
.idea/graduation_design.iml
generated
@ -1,8 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.10 (graduation_design)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
7
.idea/misc.xml
generated
7
.idea/misc.xml
generated
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.10 (graduation_design)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (graduation_design)" project-jdk-type="Python SDK" />
|
||||
</project>
|
11
.idea/saveactions_settings.xml
generated
Normal file
11
.idea/saveactions_settings.xml
generated
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SaveActionSettings">
|
||||
<option name="actions">
|
||||
<set>
|
||||
<option value="activate" />
|
||||
<option value="reformat" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
95
.idea/workspace.xml
generated
95
.idea/workspace.xml
generated
@ -4,66 +4,14 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="ed9ba2d3-2366-49b5-9e96-c67755cbd3c6" name="更改" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/abandon_code/contour_line.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/img_process/take_photos.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/img_process/train/package-seg.yaml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/img_process/train/train.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/img_process/train/yolov8n-seg.pt" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/img_process/train/yolov8n.pt" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/FRRobot.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/ConveyorTrack.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/ConveyorTrackRecord.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/ConveyorTrackSet.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/TrajectoryJ_repetition.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_compliance.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_control.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_find_surface_calcenter.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_guard.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_load_identification.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_payload_identify.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_rot_insertion.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_sensor_set.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_spiral_search.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/froce_line_insertion.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/getDHcomp.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/get_robot_data.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/getversion.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/io_interface.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/jog.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/movec&circle&newspiral.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/movej&movel&movecart.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/offset.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_basic_interface.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_common_set.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_external_device.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_log_interface.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_lua_test.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_point_table_download.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_point_table_switch.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_point_table_upload.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_safety_set.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_updata_lua.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/servo.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/spline.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/tpd_record.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/tpd_repetition.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/webapp_program_use_interface.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/robot_control/examples/weld.py" afterDir="false" />
|
||||
<list default="true" id="31e8b3f2-5159-47b8-a798-4b06368c40f5" name="更改" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/.idea/saveactions_settings.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/copilot/chatSessions/00000000000.xd" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/copilot/chatSessions/00000000000.xd" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/graduation_design.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/graduation_design.iml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/saveactions_settings.xml" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/fairino_robot_control/MoveItDemo.py" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/fairino_robot_control/__init__.py" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/fairino_robot_control/fairino/Robot.pyd" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/fairino_robot_control/robot_basic_interface.py" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/img_process/Log/OrbbecSDK.log.txt" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/img_process/ObjectClassify.py" beforeDir="false" afterPath="$PROJECT_DIR$/img_process/ObjectClassify.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/img_process/orbbec_camera/OrbbecCamera.py" beforeDir="false" afterPath="$PROJECT_DIR$/img_process/orbbec_camera/OrbbecCamera.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/robot_control/control.py" beforeDir="false" afterPath="$PROJECT_DIR$/robot_control/control.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -80,36 +28,26 @@
|
||||
"customColor": "",
|
||||
"associatedIndex": 7
|
||||
}</component>
|
||||
<component name="ProjectId" id="2eOTokNMuBujowqd2B2FN0Cy4oP" />
|
||||
<component name="ProjectId" id="2eR19ZzVWulySG5i3iRgGhf9u5g" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Python.FRRobot.executor": "Run",
|
||||
"Python.ObjectClassify.executor": "Run",
|
||||
"Python.OrbbecCamera.executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"last_opened_file_path": "F:/Projects/PyCharmProjects/graduation_design/img_process/orbbec_camera",
|
||||
"last_opened_file_path": "F:/Jetbrains/PyCharm Professional",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable",
|
||||
"settings.editor.selected.configurable": "settings.saveactions",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="F:\Projects\PyCharmProjects\graduation_design\img_process\orbbec_camera" />
|
||||
</key>
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="F:\Projects\PyCharmProjects\graduation_design\.venv\Lib\site-packages" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
@ -120,16 +58,15 @@
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="默认任务">
|
||||
<changelist id="ed9ba2d3-2366-49b5-9e96-c67755cbd3c6" name="更改" comment="" />
|
||||
<created>1711774803960</created>
|
||||
<changelist id="31e8b3f2-5159-47b8-a798-4b06368c40f5" name="更改" comment="" />
|
||||
<created>1711852426907</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1711774803960</updated>
|
||||
<workItem from="1711774807449" duration="391000" />
|
||||
<workItem from="1711775397606" duration="189000" />
|
||||
<workItem from="1711775744696" duration="1324000" />
|
||||
<workItem from="1711782281772" duration="70000" />
|
||||
<workItem from="1711784888401" duration="87000" />
|
||||
<updated>1711852426907</updated>
|
||||
<workItem from="1711852430019" duration="293000" />
|
||||
<workItem from="1711852735033" duration="1092000" />
|
||||
<workItem from="1711856889730" duration="76000" />
|
||||
<workItem from="1711857077648" duration="10854000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -137,8 +74,6 @@
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||
<SUITE FILE_PATH="coverage/graduation_design$FRRobot.coverage" NAME="FRRobot 覆盖结果" MODIFIED="1711776143556" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/robot_control" />
|
||||
<SUITE FILE_PATH="coverage/graduation_design$ObjectClassify.coverage" NAME="ObjectClassify 覆盖结果" MODIFIED="1711784964632" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/img_process" />
|
||||
<SUITE FILE_PATH="coverage/graduation_design$OrbbecCamera.coverage" NAME="OrbbecCamera 覆盖结果" MODIFIED="1711784959884" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/img_process/orbbec_camera" />
|
||||
<SUITE FILE_PATH="coverage/graduation_design$ObjectClassify.coverage" NAME="ObjectClassify 覆盖结果" MODIFIED="1711875775540" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/img_process" />
|
||||
</component>
|
||||
</project>
|
@ -1,40 +1,60 @@
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from time import sleep
|
||||
|
||||
import torch
|
||||
from torch import tensor
|
||||
from ultralytics import YOLO
|
||||
import cv2
|
||||
from orbbec_camera.OrbbecCamera import OrbbecCamera
|
||||
|
||||
# 全局变量
|
||||
model = YOLO('yolov8n.pt')
|
||||
image_width = 640
|
||||
camera = OrbbecCamera('HW', True, image_width=image_width)
|
||||
|
||||
class ObjectClassify:
|
||||
def __init__(self, image_width=640):
|
||||
self.model = YOLO('yolov8n.pt')
|
||||
# 输入的视频的宽度
|
||||
self.image_width = image_width
|
||||
|
||||
def init():
|
||||
global image_width
|
||||
# 检测GPU是否存在
|
||||
if not torch.cuda.is_available():
|
||||
print("你忘了打开独显,大聪明")
|
||||
exit(1)
|
||||
# 输入的视频的宽度
|
||||
image_width = 640
|
||||
camera.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
classify = ObjectClassify()
|
||||
camera = OrbbecCamera('HW', True, image_width=classify.image_width)
|
||||
camera.run()
|
||||
# 初始化
|
||||
init()
|
||||
|
||||
# 处理循环
|
||||
while True:
|
||||
color_image = camera.get_color_image()
|
||||
|
||||
if color_image is not None:
|
||||
# conf: 置信度,小于该值的框将被过滤
|
||||
# imgsz: 图像的尺寸
|
||||
# half: 是否使用FP16,可有效提升速度
|
||||
# vid_stride: 帧预测间隔,可降低算力消耗(间隔x帧进行一次预测)
|
||||
results = classify.model.predict(source=color_image,
|
||||
show=True,
|
||||
conf=0.5,
|
||||
half=True,
|
||||
imgsz=classify.image_width,
|
||||
verbose=False,
|
||||
vid_stride=1000)
|
||||
# for r in results:
|
||||
# print(r.boxes) # print the Boxes object containing the detection bounding boxes
|
||||
results = model.predict(source=color_image,
|
||||
show=True,
|
||||
conf=0.5,
|
||||
half=True,
|
||||
imgsz=image_width,
|
||||
verbose=False,
|
||||
vid_stride=1000)
|
||||
print("中心点的深度值: ", camera.get_center_distance(), "mm")
|
||||
for r in results:
|
||||
if len(r.boxes.xyxy) > 0:
|
||||
positions = r.boxes.xywh.tolist()
|
||||
print("X中心点:", positions[0][0])
|
||||
print("Y中心点:", positions[0][1])
|
||||
print("宽度", positions[0][2])
|
||||
print("高度", positions[0][3])
|
||||
|
||||
# print("中心点的深度值: ", camera.get_center_distance(), "mm")
|
||||
key = cv2.waitKey(1)
|
||||
if key == ord('q'):
|
||||
camera.stop()
|
||||
|
Loading…
Reference in New Issue
Block a user