export type GetApiPeripheryCamerasCaptureColorArgs = {result_type?: ('rgb_png' | 'jpeg') | undefined, camera_prim_path?: (string | null) | undefined, width?: number | undefined, height?: number | undefined}; export type GetApiPeripheryCamerasCaptureColorOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Capture Color Image * * GET /periphery/cameras/capture/color */ export const getApiPeripheryCamerasCaptureColor = async (args: GetApiPeripheryCamerasCaptureColorArgs, options: GetApiPeripheryCamerasCaptureColorOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.result_type != null) query.append("result_type", String(args.result_type)) if (args.camera_prim_path != null) query.append("camera_prim_path", String(args.camera_prim_path)) if (args.width != null) query.append("width", String(args.width)) if (args.height != null) query.append("height", String(args.height)) const url = `${baseUrl.replace(/\/+$/, '')}/periphery/cameras/capture/color${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };