-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Semi-automatic tools enhancements (Client-side points minimizer) #3450
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2bf427e
First stage for points minimizer
57fbbe2
Fixed issue with correct opencv initialization status
dd63985
Displaying points during interaction
b6cb02f
Added releasing memory
367383a
Initial version for on-the-fly optimization
b2d9548
Redesigned accuracy
4636548
Updated version & changelog
725dafa
Fixed opencv scissors
90d69bc
Clean up some intermediate state
c111668
Fixed scss
ca42cb5
Redesigned slider a bit
1117bf8
Added errored shape
bbe5c75
Keep slider hidden while didn't recieve first points
b137176
Adjusted settings slider
b62d6bf
Updated label
a1be09c
A couple of fixes for trackers & detectors
2d9f04f
Merged develop
1197639
Updated default value
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 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
This file contains 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
This file contains 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
This file contains 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
76 changes: 76 additions & 0 deletions
76
...omponents/annotation-page/standard-workspace/controls-side-bar/approximation-accuracy.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import React, { CSSProperties } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import Text from 'antd/lib/typography/Text'; | ||
import Slider from 'antd/lib/slider'; | ||
import { Col, Row } from 'antd/lib/grid'; | ||
|
||
interface Props { | ||
approxPolyAccuracy: number; | ||
onChange(value: number): void; | ||
} | ||
|
||
export const MAX_ACCURACY = 13; | ||
|
||
export const marks: Record<number, { style: CSSProperties; label: JSX.Element }> = {}; | ||
marks[0] = { | ||
style: { | ||
color: '#1890ff', | ||
}, | ||
label: <strong>less</strong>, | ||
}; | ||
marks[MAX_ACCURACY] = { | ||
style: { | ||
color: '#61c200', | ||
}, | ||
label: <strong>more</strong>, | ||
}; | ||
|
||
export function thresholdFromAccuracy(approxPolyAccuracy: number): number { | ||
const approxPolyMaxDistance = MAX_ACCURACY - approxPolyAccuracy; | ||
let threshold = 0; | ||
if (approxPolyMaxDistance > 0) { | ||
if (approxPolyMaxDistance <= 8) { | ||
// −2.75x+7y+1=0 linear made from two points (1; 0.25) and (8; 3) | ||
threshold = (2.75 * approxPolyMaxDistance - 1) / 7; | ||
} else { | ||
// 4 for 9, 8 for 10, 16 for 11, 32 for 12, 64 for 13 | ||
threshold = 2 ** (approxPolyMaxDistance - 7); | ||
} | ||
} | ||
|
||
return threshold; | ||
} | ||
|
||
function ApproximationAccuracy(props: Props): React.ReactPortal | null { | ||
const { approxPolyAccuracy, onChange } = props; | ||
const target = window.document.getElementsByClassName('cvat-canvas-container')[0]; | ||
|
||
return target ? | ||
ReactDOM.createPortal( | ||
<Row align='middle' className='cvat-approx-poly-threshold-wrapper'> | ||
<Col span={5}> | ||
<Text>Points: </Text> | ||
</Col> | ||
<Col offset={1} span={18}> | ||
<Slider | ||
value={approxPolyAccuracy} | ||
min={0} | ||
max={MAX_ACCURACY} | ||
step={1} | ||
dots | ||
tooltipVisible={false} | ||
onChange={onChange} | ||
marks={marks} | ||
/> | ||
</Col> | ||
</Row>, | ||
target, | ||
) : | ||
null; | ||
} | ||
|
||
export default React.memo(ApproximationAccuracy); |
Oops, something went wrong.
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.
Can the threshold be negative?
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.
If approxPolyAccuracy == 13, it will be -1/7
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.
No, approxPolyMaxDistance is an integer >= 1 and <= 8 in this piece of code.
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.
if approxPolyAccuracy == 13, then approxPolyMaxDistance == 0 and the condition in line 35 is false