first commit

This commit is contained in:
lyxyes 2024-09-24 14:08:45 +08:00
parent 2640837467
commit 9a2ec10759
750 changed files with 101275 additions and 0 deletions

8
丝束检测/.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="yolov8" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="ultralytics-mainV2" project-jdk-type="Python SDK" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ultralytics-main.iml" filepath="$PROJECT_DIR$/.idea/ultralytics-main.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="ultralytics-mainV2" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="GOOGLE" />
<option name="myDocStringFormat" value="Google" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="py.test" />
</component>
</module>

View File

@ -0,0 +1,67 @@
import cv2
import os
def draw_boxes(image, labels, w, h):
for line in labels:
parts = line.strip().split()
class_id = int(parts[0])
x_center = float(parts[1])
y_center = float(parts[2])
width = float(parts[3])
height = float(parts[4])
# 计算边框的左上角和右下角坐标
x_center *= w
y_center *= h
width *= w
height *= h
x_min = int(x_center - width / 2)
y_min = int(y_center - height / 2)
x_max = int(x_center + width / 2)
y_max = int(y_center + height / 2)
# 画出边框
color = (0, 255, 0) # 绿色边框
thickness = 10
image = cv2.rectangle(image, (x_min, y_min), (x_max, y_max), color, thickness)
return image
def process_folder(image_folder, label_folder, output_folder):
if not os.path.exists(output_folder):
os.makedirs(output_folder)
image_files = [f for f in os.listdir(image_folder) if f.endswith(('.jpg', '.jpeg', '.png'))]
for image_file in image_files:
image_path = os.path.join(image_folder, image_file)
label_file = os.path.splitext(image_file)[0] + '.txt'
label_path = os.path.join(label_folder, label_file)
if os.path.exists(label_path):
# 读取图片
image = cv2.imread(image_path)
h, w, _ = image.shape
# 读取标签文件
with open(label_path, 'r') as file:
labels = file.readlines()
# 绘制边框
image_with_boxes = draw_boxes(image, labels, w, h)
# 保存结果图片
output_path = os.path.join(output_folder, image_file)
cv2.imwrite(output_path, image_with_boxes)
print(f'Processed {image_file}')
else:
print(f'No label file found for {image_file}')
# 示例用法
image_folder = 'testTiaoJuan/cutJPGOnlyTiaoJuan'
label_folder = 'testTiaoJuan/CutedLabels_tiaojuan'
output_folder = 'runs/test/cuted_conf0.035'
process_folder(image_folder, label_folder, output_folder)

View File

@ -0,0 +1,77 @@
import os
import cv2
import numpy as np
def detect_edges(image_path, low_threshold, high_threshold):
"""使用 Canny 算法进行边缘检测"""
image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
if image is None:
raise ValueError(f"Failed to load image from {image_path}")
blurred_image = cv2.GaussianBlur(image, (5, 5), 0)
edges = cv2.Canny(blurred_image, low_threshold, high_threshold)
return edges
def find_edge_bounds(edges):
"""找到边缘检测结果中的最远边界"""
# 获取所有边缘点的坐标
y_coords, x_coords = np.nonzero(edges)
if len(x_coords) == 0 or len(y_coords) == 0:
return None # 如果没有检测到边缘,返回 None
# 计算边缘点的最小和最大坐标
min_x = np.min(x_coords)
max_x = np.max(x_coords)
min_y = np.min(y_coords)
max_y = np.max(y_coords)
return min_x, max_x, min_y, max_y
def crop_image(image, min_x, max_x, min_y, max_y):
"""从图像中截取指定区域"""
return image[min_y:max_y, min_x:max_x]
def process_image(image_path, output_path, low_threshold, high_threshold):
"""处理单张图像,进行边缘检测并截取指定区域"""
edges = detect_edges(image_path, low_threshold, high_threshold)
image = cv2.imread(image_path)
if image is None:
raise ValueError(f"Failed to load image from {image_path}")
bounds = find_edge_bounds(edges)
if bounds is None:
print(f"No edges detected in {image_path}")
return
min_x, max_x, min_y, max_y = bounds
cropped_image = crop_image(image, min_x, max_x, min_y, max_y)
cv2.imwrite(output_path, cropped_image)
print(f"Saved cropped image to {output_path}")
def process_images_in_folder(input_folder, output_folder, low_threshold, high_threshold):
"""处理文件夹中的所有图像文件,进行边缘检测并截取指定区域"""
if not os.path.exists(output_folder):
os.makedirs(output_folder)
for filename in os.listdir(input_folder):
if filename.lower().endswith(('.png', '.jpg', '.jpeg')):
image_path = os.path.join(input_folder, filename)
output_path = os.path.join(output_folder, filename)
process_image(image_path, output_path, low_threshold, high_threshold)
# 设置参数
input_folder = r'/mnt/d/slikDetect/datasets/AlreadyCheckOnlyTiaoJuan/OnlyTiaoJuanImages/' # 输入文件夹路径
output_folder = 'edge_cut_original' # 输出文件夹路径
low_threshold = 50 # Canny 边缘检测的低阈值
high_threshold = 150 # Canny 边缘检测的高阈值
# 处理文件夹中的所有图像
process_images_in_folder(input_folder, output_folder, low_threshold, high_threshold)

View File

@ -0,0 +1,8 @@
from ultralytics import YOLO
model = YOLO("/mnt/d/fiber/yolov8/ultralytics-main/ultralytics-main/runs/detect/train/weights/best.pt")
model.predict(source="/mnt/d/fiber/droneData/train/images", save=True, save_conf=True,
imgsz=1024,
conf=0.001, hide_labels=True, classes=0)
# D:\fiber\yolov8\ultralytics-main\ultralyti
# cs-main\runs\detect\train\weights\best.pt

View File

@ -0,0 +1,3 @@
0 0.7716272582441114 0.7858512318382819 0.07087834175588864 0.2981699305116867
0 0.2659527880085653 0.9696753000631714 0.044647112633832975 0.5912811118130133
0 0.9657388539614561 0.8938714466203411 0.06070698758029978 0.25395009475679087

View File

@ -0,0 +1 @@
0 0.16461556724820722 0.30543796579108123 0.051589421128117305 0.24923634697617594

View File

@ -0,0 +1,3 @@
0 0.39730301958685643 0.6747156270959085 0.03178840201220164 0.3977183098591549
0 0.48260764893503155 0.5902062374245471 0.036711928930750294 0.3386995305164319
0 0.14021150551214814 0.6002696177062375 0.030718287487958903 0.40710798122065733

View File

@ -0,0 +1 @@
0 0.1463131585143958 0.8213423780487805 0.05212457840094188 0.23719329268292683

View File

@ -0,0 +1,3 @@
0 0.6317031052124585 0.5688133490844655 0.07620715573156374 0.33609096278795036
0 0.8918979514074707 0.28411222681630255 0.04709404002996896 0.18901240401653868
0 0.2895219848014556 0.9450685174246897 0.05640603660494487 0.4311884229178973

View File

@ -0,0 +1,2 @@
0 0.11944778336722679 0.7691815346225825 0.08979961040351064 0.6213362445414847
0 0.9998925090442042 0.6369326263256396 0.010810156908915765 0.21085589519650655

View File

@ -0,0 +1,3 @@
0 0.9043132801027508 0.5209850119904078 0.04859220036390881 0.38609112709832133
0 0.08220029712083914 0.7991594724220622 0.036176871668628915 0.30335851318944845
0 0.6096537454778979 0.7757799760191847 0.04249154746869314 0.29256474820143885

View File

@ -0,0 +1 @@
0 0.9905815125762603 0.7105605590062112 0.04313361618323879 0.3863347826086957

View File

@ -0,0 +1,3 @@
0 0.665739247779086 0.8626952720207255 0.07845439623247351 0.27914313471502594
0 0.7881843519212244 0.4158060233160623 0.028685069891897678 0.30570142487046637
0 0.8129079978593599 0.881478303108808 0.04463277662421064 0.27590608808290157

View File

@ -0,0 +1,4 @@
0 0.635770040458097 0.8931710615280595 0.05597799079524778 0.539553752535497
0 0.8134430551214813 0.6855966869506424 0.04463277662421064 0.5956720757268424
0 0.9158730172321524 0.8262332657200812 0.03275150508402012 0.39147937795807974
0 0.5112922187734132 0.4394844489519948 0.03178840201220164 0.20621839080459772

View File

@ -0,0 +1 @@
0 0.6755863016161833 0.9099577080491131 0.04067235277748047 0.5504788540245565

View File

@ -0,0 +1,3 @@
0 0.9740982485283102 0.4108544749823821 0.06646711334689072 0.32980902043692745
0 0.9989294059723857 0.6363615221987315 0.04859220036390881 0.22550951374207187
0 0.05019737215027294 0.3157181113460184 0.03339357379856577 0.24313037350246652

View File

@ -0,0 +1 @@
0 0.5986295656641337 0.9297443037974683 0.07834738478004924 0.7651886075949368

View File

@ -0,0 +1,2 @@
0 0.17103680445253133 0.7820901690670008 0.05212457840094188 0.27301314965560425
0 0.5471480560847694 0.942393237319975 0.04666599422027186 0.4326850344395742

View File

@ -0,0 +1,2 @@
0 0.06347029262549503 0.9867905660377355 0.03467871133468907 0.21132075471698114
0 0.1591560329658568 0.43773742138364763 0.026650852188804454 0.16918427672955974

View File

@ -0,0 +1 @@
0 0.9994644632345071 0.7297134185303515 0.04313361618323879 0.4677297124600639

View File

@ -0,0 +1 @@
0 0.1348599327839024 0.6761200378071834 0.038317100717114416 0.3358544423440454

View File

@ -0,0 +1,4 @@
0 0.03500669821218285 0.373389638258737 0.035114273846483246 0.30962660944206005
0 0.4875284856011134 0.5836900674432862 0.04068106112835885 0.31514592274678105
0 0.9994648487313991 0.5328016554261189 0.06059345423402206 0.3923991416309012
0 0.33208407836420084 0.8516256897608829 0.04121623295150412 0.27283690987124465

View File

@ -0,0 +1,3 @@
0 0.5728348050947234 0.3389177529484789 0.052552624210638985 0.30229484792054623
0 0.2570910140211924 0.846680633147114 0.08466206058011345 0.22532526381129733
0 1 0.837366852886406 0.09108374783260195 0.42147734326505276

View File

@ -0,0 +1,3 @@
0 0.6333077769453067 0.7646648783977106 0.054585841806700196 0.6502138769670959
0 0.8071283793214171 0.9628029327610875 0.05265963566306325 0.748213876967096
0 0.9822331191266189 0.5486437768240344 0.04024430696778336 0.3018612303290415

View File

@ -0,0 +1,3 @@
0 0.45902131216477154 0.5991906523201075 0.07863113323321176 0.5642225958305312
0 0.999034747908174 0.7343655010087423 0.05717661960952585 0.6301271015467385
0 0.3557175885003218 0.7525221923335574 0.04280177472645355 0.28984330867518493

View File

@ -0,0 +1,3 @@
0 0.897784581397838 0.6886867233485942 0.04516783388633202 0.4303466317854807
0 0.33137146355560315 0.81295160235448 0.04217051311142032 0.2576860693263571
0 0.7545757551107781 0.6219761281883583 0.07470799529059188 0.2491844342707652

View File

@ -0,0 +1,4 @@
0 0.7032437434964136 0.5748144888287067 0.02580028348142597 0.22274881516587677
0 0.9995723832566107 0.8469851049424508 0.024836974199764477 0.6492890995260664
0 0.5390210178781715 0.683821597833446 0.04217954223316562 0.5991895734597157
0 0.8490525571137993 0.5788784698713608 0.03275851750347928 0.239

View File

@ -0,0 +1,3 @@
0 0.4510327697741625 0.7867132890365447 0.04184947875414749 0.1913627906976744
0 0.3579148042384673 0.5674411960132888 0.05383676163973027 0.26644651162790695
0 0.4727605950979343 0.47109933554817285 0.05116147532912341 0.34153023255813947

View File

@ -0,0 +1,4 @@
0 0.11099237846516108 0.6986469594594594 0.06453990709622176 0.3635128378378378
0 0.7474039875842876 0.8831064189189192 0.054585841806700196 0.5729736486486486
0 0.9985013601626885 0.5574314189189187 0.04816415455421171 0.3128385135135135
0 0.4228837572514182 0.7540557432432431 0.0584392542010061 0.30946148648648647

View File

@ -0,0 +1,3 @@
0 0.4102539055977737 0.9436357504749843 0.03628388312105319 0.28752355921469286
0 0.8433054010061009 0.8030399303356552 0.06946373404688001 0.24699183027232427
0 0.847265574826073 0.5592153894870169 0.07192549750615435 0.17036111462951237

View File

@ -0,0 +1,2 @@
0 0.8691001615755111 0.43598365068942885 0.06400514986620999 0.3650690741956665
0 0.9995716747083379 0.6460912015758371 0.02825642401798138 0.22783965856861457

View File

@ -0,0 +1 @@
0 0.3368300477362732 0.9528589225589229 0.04024430696778336 0.46464444444444447

View File

@ -0,0 +1,2 @@
0 0.9925072186663813 0.9444794952681389 0.08583918655678048 0.5993678233438486
0 0.6685215455421171 0.33312334384858044 0.052017566948517606 0.28958801261829653

View File

@ -0,0 +1,4 @@
0 0.6263510324306967 0.4746164340101522 0.048057143101787436 0.29124175126903556
0 0.25944576602804237 0.9574876269035534 0.04613093695815049 0.3236034263959391
0 0.18398819051696455 0.9600282360406088 0.0401372955153591 0.3439105329949238
0 0.46376963288023115 0.425127855329949 0.03863813507438724 0.3978407360406091

View File

@ -0,0 +1,3 @@
0 0.27517894980199076 0.43058317338451674 0.036176871668628915 0.32949264235444653
0 0.41421432944450387 0.9200278310940497 0.029755184416140428 0.3378138195777351
0 0.9994644632345071 0.4894427383237364 0.020871233650861607 0.42674472168905947

View File

@ -0,0 +1,3 @@
0 0.5991651229797709 0.6876513788968825 0.04259855892111741 0.28057494004796163
0 0.2672586021620465 0.5263806954436452 0.05116147532912341 0.3776978417266187
0 0.8774479049555817 0.6792538968824938 0.03232345927432302 0.23321163069544365

View File

@ -0,0 +1 @@
0 0.8085195282029327 0.830627190136275 0.05223158985336616 0.5535360155743023

View File

@ -0,0 +1,2 @@
0 0.16397304848549715 0.8484059175531915 0.033072539441292945 0.18550465425531912
0 0.5019802221984373 0.7779242021276594 0.04602392550572621 0.17353856382978725

View File

@ -0,0 +1 @@
0 0.043561661992935895 0.688373546511628 0.04345465054051161 0.28023197674418604

View File

@ -0,0 +1,2 @@
0 0.2985124469656427 0.9616455965909093 0.03970924970566199 0.30326704545454547
0 0.22123517670983628 0.8437517755681818 0.0337146081558386 0.4282677556818182

View File

@ -0,0 +1,4 @@
0 0.4816440458096971 0.8676088709677419 0.037246986192871666 0.385752688172043
0 0.64786483484962 0.880378696236559 0.07395891512362196 0.8568555107526882
0 0.36733381226586753 0.34542909946236544 0.021727325270255806 0.15927352150537635
0 0.5674842324735095 0.7788975134408604 0.045381856791180564 0.5026875

View File

@ -0,0 +1,3 @@
0 1 0.41701827441581796 0.06593205608476935 0.252247453565009
0 0.6454030713903457 0.7944898142600358 0.043668673445360164 0.3025769922109047
0 0.49009995076527885 0.45056920311563825 0.052552624210638985 0.32174835230677057

View File

@ -0,0 +1,2 @@
0 0.3659421633308359 0.7092710674157304 0.053087681472760356 0.5786502808988765
0 0.6594240719255057 0.43609655898876404 0.04516783388633202 0.21067345505617976

View File

@ -0,0 +1,3 @@
0 0.5243501162367549 0.7472214239059437 0.04217051311142032 0.25473416067929455
0 0.7695603587712726 0.4441548007838016 0.05576396789039923 0.32919660352710645
0 0.1283317341325056 0.6074454604833441 0.03564181440650755 0.16002612671456568

View File

@ -0,0 +1,3 @@
0 0.9537615720860537 0.6837032471437162 0.06389783838167612 0.4846668671076368
0 0.08327141175211387 0.5802754058929646 0.04559587969602911 0.3662056524353578
0 0.24595982275500372 0.8400499098015636 0.029220127154019053 0.1978352375225496

View File

@ -0,0 +1,4 @@
0 0.3950552790324307 0.871443686006826 0.0712836288130151 0.7246871444823664
0 0.15219978850476293 0.5938566552901023 0.03767503200256877 0.3742889647326507
0 0.9028151197688108 0.7195699658703072 0.05105446387669913 0.21615585893060296
0 0.6905704052231618 0.6786131968145619 0.041421432944450394 0.17804209328782708

View File

@ -0,0 +1,4 @@
0 0.5977739740982554 0.7732964391691394 0.0515895211388205 0.3382807121661721
0 0.4397940670020336 0.6724008902077151 0.07866841913732205 0.33056201780415434
0 0.7217172385743338 0.9519293768545996 0.045060822433907737 0.24094955489614242
0 0.10093080166969924 0.7519267062314541 0.0515895211388205 0.2528183976261128

View File

@ -0,0 +1,3 @@
0 0.2174887757679546 0.7919534883720928 0.07267477769453067 0.42677561282212445
0 0.36358791137750185 0.8478940917661849 0.04067235277748047 0.23569893148962917
0 0.7247140592957294 0.7115040854808299 0.041207410039601836 0.2652432432432433

View File

@ -0,0 +1,2 @@
0 0.7608909309643582 0.8224582456140352 0.04559587969602911 0.27017543859649124
0 0.17403462528095903 0.7101757894736843 0.07588612137429092 0.6196498245614036

View File

@ -0,0 +1,2 @@
0 0.8333511857005245 0.791694868662187 0.04912725762603019 0.38240867440439824
0 0.28855838167612113 0.6530247403787415 0.04452576517178636 0.5009169211973121

View File

@ -0,0 +1,4 @@
0 0.14034550873807228 0.751261994949495 0.055109262999892786 0.26641540404040404
0 0.3161789111182588 0.7866133207070706 0.050177290018226656 0.470957702020202
0 0.7564058376755656 0.515153409090909 0.04663885236410421 0.3017689393939394
0 0.9771634729280585 0.5031575126262626 0.03677490640077195 0.3295435606060606

View File

@ -0,0 +1 @@
tiaojuan

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

Some files were not shown because too many files have changed in this diff Show More