- enhancedcamera settings and region painter.
- Can send to the back end
This commit is contained in:
24
src/features/cameras/hooks/useColourDetection.ts
Normal file
24
src/features/cameras/hooks/useColourDetection.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { CAMBASE } from "../../../utils/config";
|
||||
import type { ColourDetectionPayload } from "../../../types/types";
|
||||
|
||||
const sendColourDetectionData = async (colourData: ColourDetectionPayload) => {
|
||||
const regions = {
|
||||
regions: colourData.regions,
|
||||
};
|
||||
const response = await fetch(`${CAMBASE}/TargetDetectionColour${colourData.cameraFeedID}-region-update`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(regions),
|
||||
});
|
||||
if (!response.ok) throw new Error("Cannot send data to colour detection endpoint");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const useColourDectection = () => {
|
||||
const colourMutation = useMutation({
|
||||
mutationKey: ["colour detection"],
|
||||
mutationFn: (colourData: ColourDetectionPayload) => sendColourDetectionData(colourData),
|
||||
});
|
||||
|
||||
return { colourMutation };
|
||||
};
|
||||
Reference in New Issue
Block a user