UNPKG

@techolution-ai/computer-vision

Version:

A JavaScript/TypeScript library for computer vision applications, providing tools for image processing, scanning, and MQTT-based messaging.

28 lines 1.09 kB
// src/scanner/use-scanner.tsx import { useCallback, useRef } from "react"; import HttpClient from "../helpers/http-client.js"; import { prepareRequestUrl } from "../helpers/utils.js"; var useScanner = ({ baseUrl, endpoints = {} }) => { const httpClient = useRef(new HttpClient({ baseUrl })); const getVideoStreamUrl = useCallback(() => { return endpoints.startVideoFeed || prepareRequestUrl("/video_feed?client_id=computer-vision", baseUrl); }, [endpoints.startVideoFeed, baseUrl]); const startInference = () => { return httpClient.current.get( endpoints.startInference || "/start-inference" ); }; const stopInference = () => { return httpClient.current.get(endpoints.stopInference || "/stop-inference"); }; const captureFrame = async () => { await stopInference(); return httpClient.current.get(endpoints.captureFrame || "/frame/capture"); }; return { getVideoStreamUrl, startInference, stopInference, captureFrame }; }; var use_scanner_default = useScanner; export { use_scanner_default as default }; //# sourceMappingURL=use-scanner.js.map