|
|
|
|
@ -210,6 +210,7 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
|
|
|
|
|
const { canvasInstance } = this.props;
|
|
|
|
|
canvasInstance.html().removeEventListener('canvas.interacted', this.interactionListener);
|
|
|
|
|
canvasInstance.html().removeEventListener('canvas.setup', this.runImageModifier);
|
|
|
|
|
openCVWrapper.removeProgressCallback();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private interactionListener = async (e: Event): Promise<void> => {
|
|
|
|
|
@ -286,7 +287,7 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
|
|
|
|
|
});
|
|
|
|
|
createAnnotations(jobInstance, frame, [finalObject]);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
notification.error({
|
|
|
|
|
description: error.toString(),
|
|
|
|
|
message: 'OpenCV.js processing error occured',
|
|
|
|
|
@ -342,9 +343,9 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
|
|
|
|
|
|
|
|
|
|
// update annotations on a canvas
|
|
|
|
|
fetchAnnotations();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
notification.error({
|
|
|
|
|
description: err.toString(),
|
|
|
|
|
description: error.toString(),
|
|
|
|
|
message: 'Tracking error occured',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@ -397,7 +398,7 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
|
|
|
|
|
frameData.imageData = imageBitmap;
|
|
|
|
|
canvasInstance.setup(frameData, states, curZOrder);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
notification.error({
|
|
|
|
|
description: error.toString(),
|
|
|
|
|
message: 'OpenCV.js processing error occured',
|
|
|
|
|
@ -426,7 +427,7 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
|
|
|
|
|
objectState.points = points;
|
|
|
|
|
objectState.save().then(() => {
|
|
|
|
|
shape.shapePoints = points;
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
}).catch((error: any) => {
|
|
|
|
|
reject(error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@ -590,6 +591,33 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async initializeOpenCV():Promise<void> {
|
|
|
|
|
try {
|
|
|
|
|
this.setState({
|
|
|
|
|
initializationError: false,
|
|
|
|
|
initializationProgress: 0,
|
|
|
|
|
});
|
|
|
|
|
await openCVWrapper.initialize((progress: number) => {
|
|
|
|
|
this.setState({ initializationProgress: progress });
|
|
|
|
|
});
|
|
|
|
|
const trackers = Object.values(openCVWrapper.tracking);
|
|
|
|
|
this.setState({
|
|
|
|
|
libraryInitialized: true,
|
|
|
|
|
activeTracker: trackers[0],
|
|
|
|
|
trackers,
|
|
|
|
|
});
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
notification.error({
|
|
|
|
|
description: error.toString(),
|
|
|
|
|
message: 'Could not initialize OpenCV library',
|
|
|
|
|
});
|
|
|
|
|
this.setState({
|
|
|
|
|
initializationError: true,
|
|
|
|
|
initializationProgress: -1,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private renderDrawingContent(): JSX.Element {
|
|
|
|
|
const { activeLabelID } = this.state;
|
|
|
|
|
const { labels, canvasInstance, onInteractionStart } = this.props;
|
|
|
|
|
@ -773,42 +801,21 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<Row justify='start' align='middle'>
|
|
|
|
|
<Col span={initializationProgress >= 0 ? 17 : 24}>
|
|
|
|
|
<Button
|
|
|
|
|
disabled={initializationProgress !== -1}
|
|
|
|
|
className='cvat-opencv-initialization-button'
|
|
|
|
|
onClick={async () => {
|
|
|
|
|
try {
|
|
|
|
|
this.setState({
|
|
|
|
|
initializationError: false,
|
|
|
|
|
initializationProgress: 0,
|
|
|
|
|
});
|
|
|
|
|
await openCVWrapper.initialize((progress: number) => {
|
|
|
|
|
this.setState({ initializationProgress: progress });
|
|
|
|
|
});
|
|
|
|
|
const trackers = Object.values(openCVWrapper.tracking);
|
|
|
|
|
this.setState({
|
|
|
|
|
libraryInitialized: true,
|
|
|
|
|
activeTracker: trackers[0],
|
|
|
|
|
trackers,
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
notification.error({
|
|
|
|
|
description: error.toString(),
|
|
|
|
|
message: 'Could not initialize OpenCV library',
|
|
|
|
|
});
|
|
|
|
|
this.setState({
|
|
|
|
|
initializationError: true,
|
|
|
|
|
initializationProgress: -1,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Load OpenCV
|
|
|
|
|
</Button>
|
|
|
|
|
<Col>
|
|
|
|
|
{
|
|
|
|
|
initializationProgress >= 0 ?
|
|
|
|
|
<Text>OpenCV is loading</Text> : (
|
|
|
|
|
<Button
|
|
|
|
|
className='cvat-opencv-initialization-button'
|
|
|
|
|
onClick={() => { this.initializeOpenCV(); }}
|
|
|
|
|
>
|
|
|
|
|
Reload OpenCV
|
|
|
|
|
</Button>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</Col>
|
|
|
|
|
{initializationProgress >= 0 && (
|
|
|
|
|
<Col span={6} offset={1}>
|
|
|
|
|
<Col>
|
|
|
|
|
<Progress
|
|
|
|
|
width={8 * 5}
|
|
|
|
|
percent={initializationProgress}
|
|
|
|
|
@ -857,8 +864,13 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
|
|
|
|
|
placement='right'
|
|
|
|
|
overlayClassName='cvat-opencv-control-popover'
|
|
|
|
|
content={this.renderContent()}
|
|
|
|
|
afterVisibleChange={() => {
|
|
|
|
|
if (libraryInitialized !== openCVWrapper.isInitialized) {
|
|
|
|
|
onVisibleChange={(visible: boolean) => {
|
|
|
|
|
const { initializationProgress } = this.state;
|
|
|
|
|
if (!visible || initializationProgress >= 0) return;
|
|
|
|
|
|
|
|
|
|
if (!openCVWrapper.isInitialized || openCVWrapper.initializationInProgress) {
|
|
|
|
|
this.initializeOpenCV();
|
|
|
|
|
} else if (libraryInitialized !== openCVWrapper.isInitialized) {
|
|
|
|
|
this.setState({
|
|
|
|
|
libraryInitialized: openCVWrapper.isInitialized,
|
|
|
|
|
});
|
|
|
|
|
|