make README.md

fix some bugs
This commit is contained in:
Alex Bezdieniezhnykh
2025-03-18 19:48:35 +02:00
parent b078a39097
commit 0fa2c0ddd8
4 changed files with 23 additions and 91 deletions
+13 -64
View File
@@ -1,70 +1,19 @@
# Getting Started with Create React App # Azaion Suite
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). Azaion Suite allows to user run detections on videos or photos for military-related objects, like
military vehicles, tanks, cars, military men, motos, planes, and masked objects.
Also it allows to do GPS marking by video / photos from GPS camera pointing downwards and start coordinates.
## Available Scripts ### Install
In the project directory, you can run: ```shell
npm i -g yarn
yarn install
```
### `npm start` ### Debug
`yarn start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\ ### Build prod build
You may also see any lint errors in the console. `yarn run build`
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
+1 -1
View File
@@ -42,7 +42,7 @@ function AnnotationMain() {
const handleAnnotationSave = () => { const handleAnnotationSave = () => {
const containerRef = { current: { offsetWidth: videoRef.current.videoWidth, offsetHeight: videoRef.current.videoHeight } }; const containerRef = { current: { offsetWidth: videoRef.current.videoWidth, offsetHeight: videoRef.current.videoHeight } };
const imageData = AnnotationService.createAnnotationImage(videoRef, detections, null, annotationSelectedClass, containerRef); const imageData = AnnotationService.createAnnotationImage(videoRef, detections, null, selectedClass, containerRef);
if (imageData) { if (imageData) {
setAnnotations(prevAnnotations => ({ setAnnotations(prevAnnotations => ({
...prevAnnotations, ...prevAnnotations,
+8 -8
View File
@@ -4,7 +4,7 @@ import DetectionClass from '../models/DetectionClass';
function DetectionClassList({ onClassSelect }) { function DetectionClassList({ onClassSelect }) {
const [detectionClasses, setDetectionClasses] = useState([]); const [detectionClasses, setDetectionClasses] = useState([]);
const [selectedClassId, setSelectedClassId] = useState(null); // Use an ID for selection const [selectedClass, setSelectedClass] = useState(null);
const colors = [ // Define colors *inside* the component const colors = [ // Define colors *inside* the component
"#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#FF00FF", "#00FFFF", "#000000", "#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#FF00FF", "#00FFFF", "#000000",
@@ -30,21 +30,21 @@ function DetectionClassList({ onClassSelect }) {
fetch('config.json') // Make sure this path is correct fetch('config.json') // Make sure this path is correct
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
const classObjects = data.classes.map(cls => { const detectionClasses = data.classes.map(cls => {
const color = calculateColor(cls.Id, '1'); // Full opacity for border const color = calculateColor(cls.Id, '1'); // Full opacity for border
return new DetectionClass(cls.Id, cls.Name, color); return new DetectionClass(cls.Id, cls.Name, color);
}); });
setDetectionClasses(classObjects); setDetectionClasses(detectionClasses);
if (classObjects.length > 0 && onClassSelect) { if (detectionClasses.length > 0 && onClassSelect) {
onClassSelect(classObjects[0]); // Select the first class by default onClassSelect(detectionClasses[0]); // Select the first class by default
} }
}) })
.catch(error => console.error("Error loading detection classes:", error)); .catch(error => console.error("Error loading detection classes:", error));
}, [onClassSelect]); });
const handleClassClick = (cls) => { const handleClassClick = (cls) => {
setSelectedClassId(cls.Id); // Update the selected ID setSelectedClass(cls); // Update the selected ID
onClassSelect && onClassSelect(cls); onClassSelect && onClassSelect(cls);
}; };
@@ -55,7 +55,7 @@ function DetectionClassList({ onClassSelect }) {
{detectionClasses.map((cls) => { {detectionClasses.map((cls) => {
const backgroundColor = calculateColor(cls.Id); // Calculate background color (0.2 opacity) const backgroundColor = calculateColor(cls.Id); // Calculate background color (0.2 opacity)
const darkBg = calculateColor(cls.Id, '0.8'); // Calculate selected background color (0.4 opacity) const darkBg = calculateColor(cls.Id, '0.8'); // Calculate selected background color (0.4 opacity)
const isSelected = selectedClassId === cls.Id; const isSelected = selectedClass.Id === cls.Id;
return ( return (
<li <li
+1 -18
View File
@@ -14,7 +14,7 @@ export const isMouseOverDetection = (x, y, detection, containerRef) => {
}; };
// Function to create an annotation image // Function to create an annotation image
export const createAnnotationImage = (videoRef, detections, currentDetection, selectedClass, containerRef) => { export const createAnnotationImage = (videoRef, detections, containerRef) => {
const canvas = document.createElement('canvas'); const canvas = document.createElement('canvas');
if (!containerRef.current) return null; if (!containerRef.current) return null;
const container = containerRef.current; const container = containerRef.current;
@@ -24,14 +24,10 @@ export const createAnnotationImage = (videoRef, detections, currentDetection, se
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
ctx.drawImage(videoRef.current, 0, 0, canvas.width, canvas.height); ctx.drawImage(videoRef.current, 0, 0, canvas.width, canvas.height);
const defaultColor = 'rgba(0,0,0,0.4)'
detections.forEach(detection => { detections.forEach(detection => {
const color = selectedClass && (detection.class.Id === selectedClass.Id) ? selectedClass.Color : detection.class.Color || defaultColor;
ctx.fillStyle = color.replace('1', '0.4');
ctx.fillRect(detection.x1, detection.y1, detection.x2 - detection.x1, detection.y2 - detection.y1); ctx.fillRect(detection.x1, detection.y1, detection.x2 - detection.x1, detection.y2 - detection.y1);
ctx.strokeStyle = color;
ctx.lineWidth = 2; ctx.lineWidth = 2;
ctx.strokeRect(detection.x1, detection.y1, detection.x2 - detection.x1, detection.y2 - detection.y1); ctx.strokeRect(detection.x1, detection.y1, detection.x2 - detection.x1, detection.y2 - detection.y1);
@@ -40,19 +36,6 @@ export const createAnnotationImage = (videoRef, detections, currentDetection, se
ctx.fillText(detection.class.Name, detection.x1, detection.y1 - 5); ctx.fillText(detection.class.Name, detection.x1, detection.y1 - 5);
}); });
if (currentDetection) {
const color = selectedClass ? selectedClass.Color : defaultColor;
ctx.fillStyle = color.replace('1', '0.4');
ctx.fillRect(currentDetection.x1, currentDetection.y1, currentDetection.x2 - currentDetection.x1, currentDetection.y2 - currentDetection.y1);
ctx.strokeStyle = color; // Full opacity
ctx.lineWidth = 2;
ctx.strokeRect(currentDetection.x1, currentDetection.y1, currentDetection.x2 - currentDetection.x1, currentDetection.y2 - currentDetection.y1);
ctx.fillStyle = 'white';
ctx.font = '12px Arial';
ctx.fillText(currentDetection.class.Name, currentDetection.x1, currentDetection.y1 - 5);
}
return canvas.toDataURL('image/png'); return canvas.toDataURL('image/png');
}; };