-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Semi-automatic tools enhancements (Client-side points minimizer) (#3450)
* First stage for points minimizer * Fixed issue with correct opencv initialization status * Displaying points during interaction * Added releasing memory * Initial version for on-the-fly optimization * Redesigned accuracy * Updated version & changelog * Fixed opencv scissors * Clean up some intermediate state * Fixed scss * Redesigned slider a bit * Added errored shape * Keep slider hidden while didn't recieve first points * Adjusted settings slider * Updated label * A couple of fixes for trackers & detectors * Updated default value
- Loading branch information
Boris Sekachev
authored
Jul 28, 2021
1 parent
7e7a5b9
commit 0ea4897
Showing
15 changed files
with
423 additions
and
49 deletions.
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.