-
Notifications
You must be signed in to change notification settings - Fork 692
fix: 工地防护检测BUG修复,见 issue #21 #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zltf
wants to merge
1
commit into
enpeizhao:main
Choose a base branch
from
zltf:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -102,23 +102,25 @@ def get_person_info_list(self,person_list,hat_list,vest_list): | |||||||||
|
|
||||||||||
| person_info_item[0]= person_box | ||||||||||
| # 依次与帽子计算IOU | ||||||||||
| max_hat_iou = 0 | ||||||||||
| for hat in hat_list: | ||||||||||
| hat_box = hat[:6] | ||||||||||
| hat_iou = self.get_iou(person_box, hat_box) | ||||||||||
|
|
||||||||||
| if hat_iou > hat_iou_thresh: | ||||||||||
| if hat_iou > hat_iou_thresh and hat_iou > max_hat_iou: | ||||||||||
| person_info_item[1] = hat_box | ||||||||||
| break | ||||||||||
| max_hat_iou = hat_iou | ||||||||||
|
|
||||||||||
| # 依次与防护服计算IOU | ||||||||||
| max_vest_iou = 0 | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 虽然优化后的算法能确保找到最佳匹配的对象,但时间复杂度有所增加。原实现中,一旦找到满足阈值的对象就会break,而修改后的实现需要遍历所有对象以找到最大IoU值。在对象数量较多的情况下,这可能会影响性能。建议添加注释说明这一权衡,或在性能关键场景下考虑其他优化方案。
Suggested change
|
||||||||||
| for vest in vest_list: | ||||||||||
| vest_box = vest[:5] | ||||||||||
| vest_iou = self.get_iou(person_box, vest_box) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| if vest_iou > vest_iou_thresh: | ||||||||||
| if vest_iou > vest_iou_thresh and vest_iou > max_vest_iou: | ||||||||||
| person_info_item[2] = vest_box | ||||||||||
| break | ||||||||||
| max_vest_iou = vest_iou | ||||||||||
|
|
||||||||||
| person_info_list.append(person_info_item) | ||||||||||
|
|
||||||||||
|
|
||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在修改后的代码中,虽然通过跟踪最大IoU值可以确保选择最佳匹配对象,但hat_iou_thresh和vest_iou_thresh两个阈值被硬编码为0,这可能不是最佳实践。建议将这些阈值作为参数传入函数或从配置文件中读取,以提高代码的灵活性和可维护性。