PageSourceSearch

https://guides.platerecognizer.com/assets/js/03b05cbb.d9e79dad.js

js platerecognizer.com collected 2026-10-02 05:36:11 UTC 50,140 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunktech_docs=globalThis.webpackChunktech_docs||[]).push([[4294],{14252(e,n,r){r.d(n,{A:()=>t});r(96540);var a=r(65195);const s="tableOfContentsInline_prmo";var i=r(74848);function t({toc:e,minHeadingLevel:n,maxHeadingLevel:r}){return(0,i.jsx)("div",{className:s,children:(0,i.jsx)(a.A,{toc:e,minHeadingLevel:n,maxHeadingLevel:r,className:"table-of-contents",linkClassName:null})})}},28453(e,n,r){r.d(n,{R:()=>t,x:()=>o});var a=r(96540);const s={},i=a.createContext(s);function t(e){const n=a.useContext(i);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:t(e.components),a.createElement(i.Provider,{value:n},e.children)}},39307(e,n,r){r.r(n),r.d(n,{assets:()=>d,contentTitle:()=>l,default:()=>m,frontMatter:()=>o,metadata:()=>a,toc:()=>c});const a=JSON.parse('{"id":"stream/help/usb-camera","title":"Streaming Video From a USB/CSI Camera or a Webcam","description":"Set up an RTSP server to stream USB, CSI, or webcam video to Plate Recognizer Stream on Windows, Linux, and Raspberry Pi devices.","source":"@site/docs/stream/help/usb-camera.mdx","sourceDirName":"stream/help","slug":"/stream/help/usb-camera","permalink":"/docs/stream/help/usb-camera","draft":false,"unlisted":false,"editUrl":"https://github.com/parkpow/tech-docs/edit/master/docs/stream/help/usb-camera.mdx","tags":[{"inline":true,"label":"stream","permalink":"/docs/tags/stream"},{"inline":true,"label":"usb","permalink":"/docs/tags/usb"},{"inline":true,"label":"csi","permalink":"/docs/tags/csi"},{"inline":true,"label":"camera","permalink":"/docs/tags/camera"},{"inline":true,"label":"rtsp","permalink":"/docs/tags/rtsp"},{"inline":true,"label":"webcam","permalink":"/docs/tags/webcam"},{"inline":true,"label":"raspberry-pi","permalink":"/docs/tags/raspberry-pi"}],"version":"current","frontMatter":{"title":"Streaming Video From a USB/CSI Camera or a Webcam","sidebar_label":"Onboard Cameras","description":"Set up an RTSP server to stream USB, CSI, or webcam video to Plate Recognizer Stream on Windows, Linux, and Raspberry Pi devices.","tags":["stream","usb","csi","camera","rtsp","webcam","raspberry-pi"]},"sidebar":"stream","previous":{"title":"Troubleshooting","permalink":"/docs/stream/help/troubleshooting"},"next":{"title":"Tips on Using Stream","permalink":"/docs/stream/help/tips-on-using-stream"}}');var s=r(74848),i=r(28453),t=r(14252);const o={title:"Streaming Video From a USB/CSI Camera or a Webcam",sidebar_label:"Onboard Cameras",description:"Set up an RTSP server to stream USB, CSI, or webcam video to Plate Recognizer Stream on Windows, Linux, and Raspberry Pi devices.",tags:["stream","usb","csi","camera","rtsp","webcam","raspberry-pi"]},l="USB/CSI Camera for a Webcam on Stream",d={},c=[{value:"For Windows",id:"for-windows",level:2},{value:"USB Camera For Linux",id:"usb-camera-for-linux",level:2},{value:"1. Identifying Camera and Supported Formats",id:"1-identifying-camera-and-supported-formats",level:3},{value:"2. Assigning a Persistent Camera device ID",id:"2-assigning-a-persistent-camera-device-id",level:3},{value:"3. Setting up RTSP Server on the Host Machine",id:"3-setting-up-rtsp-server-on-the-host-machine",level:3},{value:"Using <code>v4l2rtspserver</code>
1",id:"using-v4l2rtspserver",level:4},{value:"Using <code>mediamtx</code> with <code>ffmpeg</code>",id:"using-mediamtx-with-ffmpeg",level:4},{value:"4. Configuring Stream to Use the Camera",id:"4-configuring-stream-to-use-the-camera",level:3},{value:"CSI Camera For Raspberry Pi: Camera Module 2/3/4",id:"csi-camera-for-raspberry-pi-camera-module-234",level:2},{value:"Jetson USB/CSI Camera",id:"jetson-usbcsi-camera",level:2}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"usbcsi-camera-for-a-webcam-on-stream",children:"USB/CSI Camera for a Webcam on Stream"})}),"\n",(0,s.jsx)(t.A,{toc:c}),"\n",(0,s.jsx)(n.h2,{id:"for-windows",children:"For Windows"}),"\n",(0,s.jsx)(n.p,{children:"It is possible by creating an RTSP server on your host Windows OS that can be accessed by a Stream container, you just need to follow these steps:"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Create a folder on your host machine where the RTSP server files will reside."}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Go to ",(0,s.jsx)(n.a,{href:"https://github.com/bluenviron/mediamtx/releases",children:(0,s.jsx)(n.code,{children:"mediamtx releases repository"})})," and download the zip file."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Once you have it in your local folder, extract it."}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Get your camera name. You can list all your audio/video devices using this command:"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.code,{children:"ffmpeg -list_devices true -f dshow -i dummy"})}),"\n",(0,s.jsx)(n.p,{children:"Get from the results list the one you need to use i.e.:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-powershell",children:'...\n[dshow @ 000001c636eadcc0] "c922 Pro Stream Webcam" (video)\n...\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Copy the descriptive name in quotation marks (i.e.: ",(0,s.jsx)(n.code,{children:"c922 Pro Stream Webcam"}),") and paste it on the required field in the ",(0,s.jsx)(n.code,{children:"mediamtx.yml"})," file."]}),"\n",(0,s.jsx)(n.p,{children:'You can also find the camera name in the Windows Device Manager under the "Cameras" or "Imaging devices" section.'}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Open the ",(0,s.jsx)(n.code,{children:"mediamtx.yml"})," file in a text editor and make the following changes in ",(0,s.jsx)(n.code,{children:"paths"})," section, replacing ",(0,s.jsx)(n.code,{children:"<YOUR_VIDEO_CAMERA_NAME>"})," with the name of your camera."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yml",metastring:'title="mediamtx.yml"',children:'paths:\n  camera01:\n    runOnInit: ffmpeg -f dshow -video_size 1280x720 -framerate 30 -i video="<YOUR_VIDEO_CAMERA_NAME>" -pix_fmt yuv420p -c:v libx264 -preset ultrafast -b:v 600k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH\n    runOnInitRestart: yes\n'})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"https://www.ffmpeg.org/ffmpeg-devices.html#dshow",children:(0,s.jsx)(n.code,{children:"Dshow"})})," Parameters used:"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"-video_size"}),": By default ",(0,s.jsx)(n.code,{children:"ffmpeg"})," receives input from camera at a ",(0,s.jsx)(n.code,{children:"640x480"})," resolution, with this parameter you can select the desired one, this example sets it to ",(0,s.jsx)(n.code,{children:"1280x720"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"-framerate"}),": Framerates or fps, this example sets it to ",(0,s.jsx)(n.code,{children:"30"}),"."]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["Replace ",(0,s.jsx)(n.code,{children:"<YOUR_VIDEO_CAMERA_NAME>"})," with the video camera name you want to use."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Save the changes you made in the file."}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Execute the ",(0,s.jsx)(n.code,{children:"mediamtx.exe"})," program. You should be able to see a Windows cmd output like this:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-powershell",children:"2024/02/06 23:55:52 INF Media
1MTX v1.5.1\n2024/02/06 23:55:52 INF configuration loaded from C:\\Users\\User\\Desktop\\mediamtx\\mediamtx.yml\n2024/02/06 23:55:52 INF [path camera01] runOnInit command started\n2024/02/06 23:55:52 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)\n2024/02/06 23:55:52 INF [RTMP] listener opened on :1935\n2024/02/06 23:55:52 INF [HLS] listener opened on :8888\n2024/02/06 23:55:52 INF [WebRTC] listener opened on :8889 (HTTP), :8189 (ICE/UDP)\n2024/02/06 23:55:52 INF [SRT] listener opened on :8890 (UDP)\nffmpeg version 6.1.1-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers\nbuilt with gcc 12.2.0 (Rev10, Built by MSYS2 project)\nconfiguration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband\nlibavutil      58. 29.100 / 58. 29.100\nlibavcodec     60. 31.102 / 60. 31.102\nlibavformat    60. 16.100 / 60. 16.100\nlibavdevice    60.  3.100 / 60.  3.100\nlibavfilter     9. 12.100 /  9. 12.100\nlibswscale      7.  5.100 /  7.  5.100\nlibswresample   4. 12.100 /  4. 12.100\nlibpostproc    57.  3.100 / 57.  3.100\nInput #0, dshow, from 'video=c922 Pro Stream Webcam':\nDuration: N/A, start: 184827.343686, bitrate: N/A\nStream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/bt709/unknown), 1280x720, 30 fps, 30 tbr, 10000k tbn\nStream mapping:\nStream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))\nPress [q] to stop, [?] for help\n[swscaler @ 0000016617efca00] deprecated pixel format used, make sure you did set range correctly\n[swscaler @ 000001661b3a7040] deprecated pixel format used, make sure you did set range correctly\n[swscaler @ 0000016617efca00] deprecated pixel format used, make sure you did set range correctly\n[swscaler @ 000001661b3a6340] deprecated pixel format used, make sure you did set range correctly\n[libx264 @ 00000166154bef80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2\n[libx264 @ 00000166154bef80] profile Constrained Baseline, level 3.1, 4:2:0, 8-bit\n[libx264 @ 00000166154bef80] 264 - core 164 r3172 c1c9931 - H.264/MPEG-4 AVC codec - Copyleft 2003-2023 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=abr mbtree=0 bitrate=600 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0\n2024/02/06 23:55:52 INF [RTSP] [conn [::1]:52234] opened\n2024/02/06 23:55:52 INF [RTSP] [session bbd94c07] created by [::1]:52234\n2024/02/06 23:55:52 INF [RTSP] [session bbd94c07] is publishing to path 'camera01', 1 track (H264)\nOutput #0, rtsp, to 'rtsp://localhost:8554/camera01':\nMetadata:\n    encoder         : Lavf60.16.100\nStream #0:0: Video: h264, yuv420p(tv, bt470bg/bt709/unknown, progressive), 1280x720, q=2-31, 600 kb/s, 30 fps, 90k tbn\n    Metadata:\n    encoder         : Lavc60.31.102 libx264\n    Side data:\n    cpb: bitrate max/min/avg: 0/0/600000 buffer size: 0 vbv_delay: N/A\n"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["Now that ",(0,s.jsx)(n.strong,{children:"the RTSP server is running"}),", you need to add to the parameter ",(0,s.jsx)(n.a,{href:"https://docs.docker.com/network/#drivers",children:(0,s.jsx)(n.code,{children:"--network=host"})})," to run the Stream container:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-powershell",children:"docker run... --network=host platerecognizer/alpr-stream:latest\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Once the Stream container is running, just open the Stream ",(0,s.jsx)(n.code,{children:"config.ini"})," file and add the URL of the RTSP server running in the host machine to the ",(0,s.jsx)(n.code,{children:"url"})," field in the camera section."]}),"\n",(0,s.jsxs)(n.p,{children:["More information about the URL configuration ",(0,s.jsx)(n.a,{href:"/docs/stream/configuration#url",children:"here"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Make sure to use the correct URL."}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Format:"}),(0,s.jsx)(n.code,{children:"rtsp://<HOST_IP_ADDRESS>:<RTSP_PORT>/<CAMERA_SERVER_PATH>"})]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Example:"})," ",(0,s.jsx)(n.code,{children:"rtsp://192.168.1.100:8554/camera01"})]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"rtsp"})," is the service protocol."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"192.168.1.100"})," is the Windows host machine IP address."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"8554"})," is the default RTSP port."]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"camera01"})," is the camera path in the server."]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["In general, if you are running the Stream container in the same host machine as the RTSP server, you can use ",(0,s.jsx)(n.code,{children:"localhost"})," or ",(0,s.jsx)(n.code,{children:"127.0.0.1"})," as the host IP address."]}),"\n","\n",(0,s.jsx)(n.h2,{id:"usb-camera-for-linux",children:"USB Camera For Linux"}),"\n",(0,s.jsx)(n.p,{children:"This tutorial will guide you through the process of setting up a USB camera (webcam) on a Linux machine to work with Plate Recognizer Stream softw
1are."}),"\n",(0,s.jsx)(n.h3,{id:"1-identifying-camera-and-supported-formats",children:"1. Identifying Camera and Supported Formats"}),"\n",(0,s.jsx)(n.p,{children:"First of all, you need to identify your camera and its supported formats, resolutions and framerates. Follow these steps:"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Make sure your camera is connected to your Linux machine and recognized by the OS.\nYou can use the command ",(0,s.jsx)(n.code,{children:"lsusb"})," to list all connected USB devices."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:"$ lsusb\nBus 002 Device 003: ID 046d:085c Logitech, Inc.\nBus 001 Device 101: ID 0458:708f KYE Systems Corp. (Mouse Systems) FaceCam 1000X\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsx)(n.p,{children:"If you don't see your camera listed, make sure it is properly connected and that you have the necessary drivers installed."})}),"\n",(0,s.jsxs)(n.admonition,{type:"note",children:[(0,s.jsx)(n.p,{children:"Please write down the camera model, vendor ID and product ID, as this information will be used later in this section."}),(0,s.jsxs)(n.p,{children:["In this example, we will use the ",(0,s.jsx)(n.code,{children:"KYE Systems Corp. FaceCam 1000X"})," camera, so:"]}),(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["Camera Model: ",(0,s.jsx)(n.code,{children:"FaceCam 1000X"})]}),"\n",(0,s.jsxs)(n.li,{children:["Vendor ID: ",(0,s.jsx)(n.code,{children:"0458"})]}),"\n",(0,s.jsxs)(n.li,{children:["Product ID: ",(0,s.jsx)(n.code,{children:"708f"})]}),"\n"]})]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Find the id of the camera. For example, ",(0,s.jsx)(n.code,{children:"/dev/video0"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:"$ ls -ltrh /dev/video*\n-rwxrw----+ 1 root root      0 Sep 24 21:15 /dev/video2\ncrw-rw----+ 1 root video 81, 1 Oct  7 14:39 /dev/video1\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Because the camera is connected via USB, it should be listed as ",(0,s.jsx)(n.code,{children:"/dev/videoX"}),", where ",(0,s.jsx)(n.code,{children:"X"})," is a number starting from ",(0,s.jsx)(n.code,{children:"0"}),". However, if you have multiple video devices connected, the number may be different."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Using ",(0,s.jsx)(n.code,{children:"v4l2-ctl"})," command, you can list all the supported formats of your camera. This command is part of the ",(0,s.jsx)(n.code,{children:"v4l-utils"})," package, which you may need to install first."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:"$ v4l2-ctl --list-formats-ext -d /dev/video1\nDriver Info:\n        Driver name      : uvcvideo\n        Card type        : FaceCam 1000X: FaceCam 1000X\n        Bus info         : usb-0000:00:14.0-2.2.4\n        Driver version   : 6.14.11\n        Capabilities     : 0x84a00001\n                Video Capture\n                Metadata Capture\n                Streaming\n                Extended Pix Format\n                Device Capabilities\n        Device Caps      : 0x04200001\n                Video Capture\n                Streaming\n                Extended Pix Format\nMedia Driver Info:\n        Driver name      : uvcvideo\n        Model            : FaceCam 1000X: FaceCam 1000X\n        Serial           :\n        Bus info         : usb-0000:00:14.0-2.2.4\n        Media version    : 6.14.11\n        Hardware revision: 0x00000004 (4)\n        Driver version   : 6.14.11\nInterface Info:\n        ID               : 0x03000002\n        Type             : V4L Video\nEntity Info:\n        ID               : 0x00000001 (1)\n        Name             : FaceCam 1000X: FaceCam 1000X\n        Function         : V4L2 I/O\n        Flags            : default\n        Pad 0x01000007   : 0: Sink\n        Link 0x02000010: from remote pad 0x100000a of entity 'Processing 2' (Video Pixel Formatter): Data, Enabled, Immutable\nPriority: 2\nVideo input : 0 (Camera 1: ok)\nFormat Video Capture:\n        Width/Height      : 640/480\n        Pixel Format      : 'MJPG' (Motion-JPEG)\n        Field             : None\n        Bytes per Line    : 0\n        Size Image        : 921600\n        Colorspace        : sRGB\n        Transfer Function : Rec. 709\n        YCbCr/HSV Encoding: ITU-R 601\n        Quantization      : Default (maps to Full Range)\n        Flags             :\nCrop Capability Video Capture:\n        Bounds      : Left 0, Top 0, Width 640, Height 480\n        Default     : Left 0, Top 0, Width 640, Height 480\n        Pixel Aspect: 1/1\nSelection Video Capture: crop_default, Left 0, Top 0, Width 640, Height 480, Flags:\nSelection Video Capture: crop_bounds, Left 0, Top 0, Width 640, Height 480, Flags:\nStreaming Parameters Video Capture:\n        Capabilities     : timeperframe\n        Frames per second: 30.000 (30/1)\n        Read buffers     : 0\n\nUser Controls\n\n                    brightness 0x00980900 (int)    : min=-255 max=255 step=1 default=0 value=0\n                    contrast 0x00980901 (int)    : min=0 max=30 step=1 default=15 value=15\n                    saturation 0x00980902 (int)    : min=0 max=127 step=1 default=32 value=32\n                            hue 0x00980903 (int)    : min=-16000 max=16000 step=1 default=0 value=0\n        white_balance_automatic 0x0098090c (bool)   : default=1 value=1\n                        gamma 0x00980910 (int)    : min=20 max=250 step=1 default=100 value=100\n        power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=1 value=1 (50 Hz)\n                                0: Disabled\n                                1: 50 Hz\n                                2: 60 Hz\n    white_balance_temperature 0x0098091a (int)    : min=2800 max=6500 step=1 default=5000 value=5000 flags=inactive\n                    sharpness 0x0098091b (int)    : min=0 max=31 step=1 default=16 value=16\n        backlight_compensation 0x0098091c (int)    : min=0 max=2 step=1 default=0 value=0\n"})}),"\n",(0,s.jsxs)(n.admonition,{type:"note",children:[(0,s.jsx)(n.p,{children:"Please write down the supported formats, resolutions and framerates of your camera, as this information will be used later in this section."}),(0,s.jsxs)(n.p,{children:["In this example, we will use the ",(0,s.jsx)(n.code,{children:"MJPG"})," format at a resolution of ",(0,s.jsx)(n.code,{children:"640x480"})," and a framerate of ",(0,s.jsx)(n.code,{children:"30 fps"}),"."]}),(0,s.jsxs)(n.p,{children:["You can also see the camera model and driver information at the top of the output. Make sure it matches the camera you want to use, as seen by the ",(0,s.jsx)(n.code,{children:"lsusb"})," command above."]})]}),"\n",(0,s.jsx)(n.p,{children:"Depending on your camera, you may see different formats, resolutions and framerates. We will discuss several methods to set the camera parameters later in this section."}),"\n",(0,s.jsx)(n.p,{children:"The supported formats may include:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"YUYV"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"MJPG"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"H264"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"UYVY"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"YUV420"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"NV12"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"RGB3"})}),"\n",(0,s.jsx)(n.li,{children:"Among others."}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"2-assigning-a-persistent-camera-device-id",children:"2. Assigning a Persistent Camera device ID"}),"\n",(0,s.jsxs)(n.p,{children:["When using a USB camera, the device id (e.g., ",(0,s.jsx)(n.code,{children:"/dev/video0"}),") may change if you connect/disconnect other video devices or reboot the machine. To avoid this, we will create a udev rule that assigns a persistent name to your camera based on its vendor ID and product ID."]}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsx)(n.p,{children:"This step is optional, but highly recommended to avoid issues with changing device ids, so that you don't have to update the camera device file every time the device id changes."})}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Identify the udev attributes of your camera using the ",(0,s.jsx)(n.code,{children:"udevadm"})," command:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:'$ udevadm info -a -n /dev/video1 | grep \'{idVendor}\\|{idProduct}\\|{serial}\\|{product}\'\nUdevadm info starts with the device specified by the devpath and then\nwalks up the chain of parent devices. It prints for every device found,\nall attributes and all tags. ...\n...\n  looking at device \'/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2.4/1-2.2.4:1.0/video4linux/video1\':\n    KERNEL=="video1"\n    SUBSYSTEM=="video4linux"\n    ...\n    ATTR{name}=="FaceCam 1000X: FaceCam 1000X"\n\n  looking at parent device \'/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2.4/1-2.2.4:1.0\':\n    ...\n\n  looking at parent device \'/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2.4/1-2.2.4\':\n    ...\n    ATTRS{idVendor}=="0458"\n    ATTRS{idProduct}=="708f"\n    ATTRS{serial}=="200901010001"\n    ATTRS{product}=="FaceCam 1000X: FaceCam 1000X"\n    ...\n'})}),"\n",(0,s.jsxs)(n.p,{children:["In this example, we will use the ",(0,s.jsx)(n.code,{children:"idVe
1ndor"})," and ",(0,s.jsx)(n.code,{children:"idProduct"})," attributes to create the udev rule."]}),"\n",(0,s.jsx)(n.p,{children:"The output is very verbose, so make sure to look for the correct device:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["Match ",(0,s.jsx)(n.code,{children:'KERNEL=="videoX"'})," and ",(0,s.jsx)(n.code,{children:'SUBSYSTEM=="video4linux"'}),". ",(0,s.jsx)(n.code,{children:"KERNEL"})," should match the ",(0,s.jsx)(n.code,{children:"/dev/videoX"})," path you found earlier."]}),"\n",(0,s.jsxs)(n.li,{children:["As a general rule, you should look for the attributes in the parent device that contains the ",(0,s.jsx)(n.code,{children:"idVendor"})," and ",(0,s.jsx)(n.code,{children:"idProduct"})," attributes that match the camera you want to use."]}),"\n",(0,s.jsxs)(n.li,{children:["Pay attention that ",(0,s.jsx)(n.code,{children:"model"})," and ",(0,s.jsx)(n.code,{children:"name"})," should also match the camera you want to use."]}),"\n",(0,s.jsxs)(n.li,{children:["You should also use the ",(0,s.jsx)(n.code,{children:"serial"})," attribute if available, especially if you have multiple cameras of the same model."]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Create a new file in ",(0,s.jsx)(n.code,{children:"/etc/udev/rules.d/"})," named ",(0,s.jsx)(n.code,{children:"99-alpr-camera.rules"})," with the following content:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-conf",metastring:'title="99-alpr-camera.rules"',children:'SUBSYSTEM=="video4linux", ATTRS{idVendor}=="0458", ATTRS{idProduct}=="708f", SYMLINK+="alpr-camera-1"\n'})}),"\n",(0,s.jsxs)(n.admonition,{type:"note",children:[(0,s.jsxs)(n.p,{children:["if you have multiple cameras of the same model, you can use the ",(0,s.jsx)(n.code,{children:"serial"})," attribute to differentiate them. For example:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-conf",metastring:'title="99-alpr-camera.rules"',children:'SUBSYSTEM=="video4linux", ATTRS{idVendor}=="0458", ATTRS{idProduct}=="708f", ATTRS{serial}=="200901010001", SYMLINK+="alpr-camera-1"\nSUBSYSTEM=="video4linux", ATTRS{idVendor}=="0458", ATTRS{idProduct}=="708f", ATTRS{serial}=="200901010002", SYMLINK+="alpr-camera-2"\n'})}),(0,s.jsxs)(n.p,{children:["Even if you have a single camera, it's a good practice to use the ",(0,s.jsx)(n.code,{children:"serial"})," attribute if your camera provides it."]})]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["Replace ",(0,s.jsx)(n.code,{children:"0458"})," and ",(0,s.jsx)(n.code,{children:"708f"})," with your camera's vendor ID and product ID, respectively."]}),"\n",(0,s.jsxs)(n.li,{children:["You can name the rule file anything you want, but it should end with ",(0,s.jsx)(n.code,{children:".rules"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:["You can also change ",(0,s.jsx)(n.code,{children:"alpr-camera"})," in ",(0,s.jsx)(n.code,{children:"SYMLINK"})," to any name you prefer. That name will be used as the persistent camera device id, i.e., ",(0,s.jsx)(n.code,{children:"/dev/alpr-camera"}),"."]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Reload the udev rules and trigger them:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:"sudo udevadm control --reload-rules\nsudo udevadm trigger\n"})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Verify that the symlink was created:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:"$ ls -l /dev/alpr-camera-1\nlrwxrwxrwx 1 root root 6 Oct  7 20:03 /dev/alpr-camera-1 -> video1\n"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["Now, you can use ",(0,s.jsx)(n.code,{children:"/dev/alpr-camera-1"})," as the camera id. Almost there! From now on, you can use ",(0,s.jsx)(n.code,{children:"/dev/alpr-camera-1"})," as the camera id, and it will always point to your USB camera, regardless of changes in device ids, as long as the camera is connected."]}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["Stream container is not able to use the webcam device directly. So, it's recommended to set up an RTSP server on the host machine and use the RTSP stream URL in Stream's ",(0,s.jsx)(n.code,{children:"config.ini"})," file."]})}),"\n",(0,s.jsx)(n.h3,{id:"3-setting-up-rtsp-server-on-the-host-machine",children:"3. Setting up RTSP Server on the Host Machine"}),"\n",(0,s.jsx)(n.p,{children:"To stream video from your USB camera to our Stream softw
1are, you have to set up an RTSP server on your host machine."}),"\n",(0,s.jsx)(n.p,{children:"Depending on camera capabilities, such as formats available, you can choose one of the following methods to set up the RTSP server:"}),"\n",(0,s.jsxs)(n.h4,{id:"using-v4l2rtspserver",children:["Using ",(0,s.jsx)(n.code,{children:"v4l2rtspserver"})]}),"\n",(0,s.jsxs)(n.p,{children:["One of the simplest ways to set up an RTSP server is by using the ",(0,s.jsx)(n.code,{children:"v4l2rtspserver"})," tool. You can install it from the package manager or build it from source."]}),"\n",(0,s.jsxs)(n.p,{children:["This will only work if your camera supports MJPEG (MJPG) or H264 formats. You can check the supported formats using the ",(0,s.jsx)(n.code,{children:"v4l2-ctl --list-formats-ext -d /dev/alpr-camera-1"})," command as shown above."]}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Download and install the V4L2 RTSP server package:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"wget https://github.com/mpromonet/v4l2rtspserver/releases/download/v0.3.11/v4l2rtspserver-0.3.11-Linux-x86_64-Release.deb\n# wget https://github.com/mpromonet/v4l2rtspserver/releases/download/v0.3.11/v4l2rtspserver-0.3.11-Linux-arm64-Release.deb  # for ARM64 architecture\nsudo apt update\nsudo apt install ./v4l2rtspserver-0.3.11-Linux-x86_64-Release.deb\n"})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Create a systemd service file to manage the RTSP server:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"sudo nano /etc/systemd/system/v4l2-rtsp.service\n"})}),"\n",(0,s.jsx)(n.p,{children:"Add the following content to the service file:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ini",metastring:'title="/etc/systemd/system/v4l2-rtsp.service"',children:'[Unit]\nDescription=v4l2 RTSP server to forward ALPR camera 1 (USB) to Stream\n\n[Service]\nExecStart=/bin/bash -c "v4l2rtspserver -W 1920 -H 1080 -F 30 -P 8554 /dev/alpr-camera-1" -u "alpr-camera-1"\nRestart=always\nUser=<YOUR_USERNAME>\n\n[Install]\nWantedBy=multi-user.target\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["Replace ",(0,s.jsx)(n.code,{children:"1920"})," and ",(0,s.jsx)(n.code,{children:"1080"})," with the resolution supported by your camera (as identified earlier)."]}),"\n",(0,s.jsxs)(n.li,{children:["Replace ",(0,s.jsx)(n.code,{children:"30"})," with the framerate supported by your camera (as identified earlier)."]}),"\n",(0,s.jsxs)(n.li,{children:["Depending on supported formats, you may need to add ",(0,s.jsx)(n.code,{children:"-fformat MJPG"})," or ",(0,s.jsx)(n.code,{children:"-fformat H264"})," to the ",(0,s.jsx)(n.code,{children:"ExecStart"})," line to specify the format explicitly."]}),"\n",(0,s.jsxs)(n.li,{children:["The RTSP path can be changed by modifying the ",(0,s.jsx)(n.code,{children:"-u"})," parameter. In this example, we set it to ",(0,s.jsx)(n.code,{children:"alpr-camera-1"}),", so the RTSP URL will be ",(0,s.jsx)(n.code,{children:"rtsp://<HOST_IP_ADDRESS>:8554/alpr-camera-1"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:["You can adjust the port by changing the ",(0,s.jsx)(n.code,{children:"-P"})," parameter. The default RTSP port is ",(0,s.jsx)(n.code,{children:"8554"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:["Replace ",(0,s.jsx)(n.code,{children:"<YOUR_USERNAME>"})," with your Linux username or any other user with access to the camera device."]}),"\n"]})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Reload systemd, enable, start, and check the status of the service:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"sudo systemctl daemon-reload\nsudo systemctl enable --now v4l2-rtsp.service\nsudo systemctl status v4l2-rtsp.service\n"})}),"\n",(0,s.jsx)(n.p,{children:"Make sure the service is running without errors."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"\u25cf v4l2-rtsp.service - v4l2 RTSP server to forward ALPR camera 1 (USB) to Stream\n   Loaded: loaded (/etc/systemd/system/v4l2-rtsp.service; enabled; vendor preset: enabled)\n   Active: active (running) since Mon 2024-10-07 20:10:00 UTC; 10s ago\n Main PID: 12345 (bash)\n    Tasks: 2 (limit: 4915)\n...\n"})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Verify that the RTSP server is running and accessible:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"$ curl rtsp://localhost:8554/alpr-camera-1\nRTSP/1.0 200 OK\nCSeq: 1\nPublic: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE\n"})}),"\n",(0,s.jsxs)(n.admonition,{type:"note",children:[(0,s.jsxs)(n.p,{children:["We strongly recommend using a media player like VLC to test the RTSP stream. Open VLC and go to ",(0,s.jsx)(n.code,{children:"Media"})," > ",(0,s.jsx)(n.code,{children:"Open Network Stream"}),", then enter the URL ",(0,s.jsx)(n.code,{children:"rtsp://localhost:8554/alpr-camera-1"}),"."]}),(0,s.jsxs)(n.p,{children:["You can also use ffplay if ",(0,s.jsx)(n.code,{children:"ffmpeg"}
1)," is installed on your system:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"ffplay rtsp://localhost:8554/alpr-camera-1\n"})}),(0,s.jsx)(n.p,{children:"That should open a window displaying the video feed from your USB camera."})]}),"\n",(0,s.jsxs)(n.admonition,{type:"warning",children:[(0,s.jsxs)(n.p,{children:["If you encounter issues, such as the stream not playing, having artifacts, low resolution, or green or black screen, make sure your camera supports the specified format, resolution, and framerate. You may need to adjust the parameters in the ",(0,s.jsx)(n.code,{children:"ExecStart"})," line of the systemd service file accordingly. Please refer to the ",(0,s.jsxs)(n.a,{href:"https://github.com/mpromonet/v4l2rtspserver?tab=readme-ov-file#usage",children:[(0,s.jsx)(n.code,{children:"v4l2rtspserver"})," documentation"]})," for more details."]}),(0,s.jsxs)(n.p,{children:["Please double-check the camera capabilities using the ",(0,s.jsx)(n.code,{children:"v4l2-ctl --list-formats-ext -d /dev/alpr-camera-1"})," command as shown above."]})]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.h4,{id:"using-mediamtx-with-ffmpeg",children:["Using ",(0,s.jsx)(n.code,{children:"mediamtx"})," with ",(0,s.jsx)(n.code,{children:"ffmpeg"})]}),"\n",(0,s.jsxs)(n.p,{children:["Another option is to use ",(0,s.jsx)(n.code,{children:"mediamtx"})," with ",(0,s.jsx)(n.code,{children:"ffmpeg"}),". This method provides more flexibility and can work with various camera formats (such as YUYV, MJPG, etc.) by leveraging ffmpeg's capabilities. It can be easily integrated into existing workflows."]}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Download and extract the MediaMTX binary:"}),"\n",(0,s.jsxs)(n.p,{children:["Go to the ",(0,s.jsx)(n.a,{href:"https://github.com/bluenviron/mediamtx/releases",children:(0,s.jsx)(n.code,{children:"mediamtx releases repository"})})," and download the appropriate archive for your Linux architecture (e.g., ",(0,s.jsx)(n.code,{children:"mediamtx_v1.x.x_linux_amd64.tar.gz"})," for x86_64 or ",(0,s.jsx)(n.code,{children:"mediamtx_v1.x.x_linux_arm64.tar.gz"})," for ARM64)."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"# Example for x86_64\nwget https://github.com/bluenviron/mediamtx/releases/download/v1.15.1/mediamtx_v1.15.1_linux_amd64.tar.gz\n## or for ARM64\n# wget https://github.com/bluenviron/mediamtx/releases/download/v1.15.1/mediamtx_v1.15.1_linux_arm64.tar.gz\ntar -xzf mediamtx_v1.15.1_linux_amd64.tar.gz\n# It's recommended to copy the binary to a directory in your PATH, e.g.: /usr/local/bin\nsudo cp mediamtx /usr/local/bin/\nsudo chmod +x /usr/local/bin/mediamtx\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["Make sure that you have ",(0,s.jsx)(n.code,{children:"ffmpeg"})," installed on your system, as it is required for this method. You can install it using your package manager, e.g., ",(0,s.jsx)(n.code,{children:"sudo apt install ffmpeg"}),"."]})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Configure MediaMTX:"}),"\n",(0,s.jsxs)(n.p,{children:["Edit the ",(0,s.jsx)(n.code,{children:"mediamtx.yml"})," configuration file. By default, it's in the same directory as the binary, or you can specify its path."]}),"\n",(0,s.jsxs)(n.p,{children:["Add or modify the ",(0,s.jsx)(n.code,{children:"paths"})," section to include your camera stream:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yml",metastring:'title="mediamtx.yml"',children:"paths:\n  alpr-camera-1:\n    runOnInit: ffmpeg -f v4l2 -video_size 1280x720 -framerate 30 -i /dev/alpr-camera-1 -pix_fmt yuv420p -c:v libx264 -preset ultrafast -b:v 600k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH\n    runOnInitRestart: yes\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["Replace ",(0,s.jsx)(n.code,{children:"1280x720"})," and ",(0,s.jsx)(n.code,{children:"30"})," with the resolution and framerate supported by your camera (as identified earlier)."]}),"\n",(0,s.jsxs)(n.li,{children:["If your camera uses a format like YUYV, you may 
1need to add ",(0,s.jsx)(n.code,{children:"-input_format yuyv422"})," after ",(0,s.jsx)(n.code,{children:"-i /dev/alpr-camera-1"})," to specify the input format explicitly."]}),"\n",(0,s.jsxs)(n.li,{children:["Adjust the bitrate (",(0,s.jsx)(n.code,{children:"-b:v 600k"}),") and other ffmpeg parameters as needed for your setup."]}),"\n"]})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Create a systemd service file to manage MediaMTX:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"sudo nano /etc/systemd/system/mediamtx.service\n"})}),"\n",(0,s.jsx)(n.p,{children:"Add the following content:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ini",metastring:'title="/etc/systemd/system/mediamtx.service"',children:"[Unit]\nDescription=MediaMTX RTSP server for ALPR camera 1\n\n[Service]\nExecStart=/usr/local/bin/mediamtx /path/to/mediamtx.yml\nRestart=always\nUser=<YOUR_USERNAME>\n\n[Install]\nWantedBy=multi-user.target\n"})}),"\n",(0,s.jsxs)(n.admonition,{type:"note",children:[(0,s.jsxs)(n.p,{children:["Replace ",(0,s.jsx)(n.code,{children:"/path/to/mediamtx.yml"})," with the actual path to your configuration file, and ",(0,s.jsx)(n.code,{children:"your-user"})," with a user that has permissions to access ",(0,s.jsx)(n.code,{children:"/dev/alpr-camera-1"})," (typically a user in the ",(0,s.jsx)(n.code,{children:"video"})," group)."]}),(0,s.jsxs)(n.p,{children:["Also, set a user that has permissions to access ",(0,s.jsx)(n.code,{children:"/dev/alpr-camera-1"})," (typically a user in the ",(0,s.jsx)(n.code,{children:"video"})," group)."]})]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Reload systemd, enable, start, and check the status of the service:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"sudo systemctl daemon-reload\nsudo systemctl enable --now mediamtx.service\nsudo systemctl status mediamtx.service\n"})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"Verify the service is active and RTSP stream works as intended, as shown in the previous method."}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"4-configuring-stream-to-use-the-camera",children:"4. Configuring Stream to Use the Camera"}),"\n",(0,s.jsx)(n.p,{children:"Now that you have your camera set up and an RTSP server running, you need to configure Stream to use the camera."}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Update the ",(0,s.jsx)(n.code,{children:"url"})," parameter in your ",(0,s.jsx)(n.code,{children:"config.ini"}),". with the RTSP URL from the running RTSP server."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:"url = 'rtsp://localhost:8554/alpr-camera-1'\n"})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Start Stream with the ",(0,s.jsx)(n.code,{children:"docker run"}),". And set your own ",(0,s.jsx)(n.code,{children:"LICENSE_KEY"}),", ",(0,s.jsx)(n.code,{children:"TOKEN"})," and volume for ",(0,s.jsx)(n.code,{children:"/path/to/stream_dir"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:"# don't use --gpus all if docker complains about it, or if you don't have a GPU.\ndocker run \\\n    --gpus all \\\n    --name stream \\\n    --net host \\\n    --restart=\"unless-stopped\" \\\n    --user `id -u`:`id -g` \\\n    -v /path/to/stream_dir:/user-data \\\n    -e LICENSE_KEY=XXXXX \\\n    -e TOKEN=YYYYY \\\n    platerecognizer/alpr-stream:latest\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["For the docker 
1container to access localhost RTSP server, you need to run the container with ",(0,s.jsx)(n.code,{children:"--net host"})," flag."]})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"csi-camera-for-raspberry-pi-camera-module-234",children:"CSI Camera For Raspberry Pi: Camera Module 2/3/4"}),"\n",(0,s.jsx)(n.p,{children:"We recommend updating your OS and packages before starting the process."}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Choose a format (use command ",(0,s.jsx)(n.strong,{children:"v4l2-ctl --list-formats-ext"})," from ",(0,s.jsx)(n.strong,{children:"v4l-utils"})," apt package) supported by camera hardware.\nFor example, width=1280, height=1080, framerate=15/1, format=UYVY."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["Set the camera ",(0,s.jsx)(n.code,{children:"url"})," in ",(0,s.jsx)(n.code,{children:"config.ini"})," to:"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'url = "libcamerasrc ! video/x-raw, width=AAAAA, height=BBBBB, framerate=CCCCC/1, format=DDDDD ! videoconvert ! video/x-raw,format=(string)BGR ! appsink max-buffers=5"\n'})}),"\n",(0,s.jsxs)(n.ol,{start:"3",children:["\n",(0,s.jsxs)(n.li,{children:["Start Stream with the ",(0,s.jsx)(n.code,{children:"docker run"}),". And set your own ",(0,s.jsx)(n.code,{children:"LICENSE_KEY"}),", ",(0,s.jsx)(n.code,{children:"TOKEN"})," and volume for ",(0,s.jsx)(n.code,{children:"/path/to/stream_dir"}),".\nNotice the new environment variables, volumes and flags."]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:'docker run \\\n    -t \\\n    --privileged \\\n    --name stream \\\n    --restart="unless-stopped" \\\n    --user `id -u`:`id -g` \\\n    --group-add video \\\n    -v /run/udev:/run/udev\n    -v /path/to/stream_dir:/user-data \\\n    -e OPENCV_API_PREFERENCE=1800 \\\n    -e LICENSE_KEY=XXXXX \\\n    -e TOKEN=YYYYY \\\n    platerecognizer/alpr-stream:arm\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Read more about ",(0,s.jsx)(n.a,{href:"https://gstreamer.freedesktop.org/",children:"Gstreamer"})," and ",(0,s.jsx)(n.a,{href:"https://github.com/raspberrypi/libcamera",children:"libcamera"}),", if you need to toggle specific camera options or switch to another device."]}),"\n",(0,s.jsx)(n.h2,{id:"jetson-usbcsi-camera",children:"Jetson USB/CSI Camera"}),"\n",(0,s.jsx)(n.p,{children:"To use onboard cameras a few additional configurations are necessary."}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"First get your available camera resolutions"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"gst-launch-1.0 nvarguscamerasrc sensor-id=0\n"})}),"\n",(0,s.jsxs)(n.ol,{start:"2",children:["\n",(0,s.jsxs)(n.li,{children:["Set the camera ",(0,s.jsx)(n.code,{children:"url"})," in ",(0,s.jsx)(n.code,{children:"config.ini"})," to:"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'url = "nvarguscamerasrc ! video/x-raw(memory:NVMM), width=AAAAA, height=BBBBB, framerate=CCCCC/1, format=NV12 ! nvvidconv flip-method=0 ! video/x-raw,width=960, height=616 ! nvvidconv ! video/x-raw ! videoconvert ! video/x-raw,format=(string)BGR ! videoconvert ! appsink max-buffers=5"\n'})}),"\n",(0,s.jsx)(n.admonition,{title:"For the commands above, make sure to:",type:"caution",children:(0,s.jsxs)(n.p,{children:["Change ",(0,s.jsx)(n.strong,{children:"AAAAA"}),", ",(0,s.jsx)(n.strong,{children:"BBBBB"}),", and ",(0,s.jsx)(n.strong,{children:"CCCCC"})," to your values available to your camera.\nThe framerate (FPS) of the camera could be any value below the available for the specified resolution."]})}),"\n",(0,s.jsxs)(n.ol,{start:"3",children:["\n",(0,s.jsxs)(n.li,{children:["Now you can run the application. Notice the new environment variable ",(0,s.jsx)(n.code,{children:"-e OPENCV_API_PREFERENCE=1800"}),", volume and device. List of ",(0,s.jsx)(n.a,{href:"https://docs.opencv.org/3.4/d4/d15/group__videoio__flags__base.html",children:"OPENCV_API_PREFERENCE"}),":"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:'docker run \\\n    -t \\\n    --runtime nvidia \\\n    --privileged \\\n    --name stream \\\n    --restart="unless-stopped" \\\n    --user `id -u`:`id -g` \\\n    --group-add video \\\n    -v /tmp/argus_socket:/tmp/argus_socket \\\n    -v /path/to/stream_dir:/user-data \\\n    -e OPENCV_API_PREFERENCE=1800 \\\n    -e LICENSE_KEY=XXXXX \\\n    -e TOKEN=YYYYY \\\n    platerecognizer/alpr-stream:jetson\n'})}),"\n",(0,s.jsxs)(n.admonition,{type:"caution",children:[(0,s.jsx)(n.p,{children:"For the commands above, make sure to:"}),(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["Change ",(0,s.jsx)(n.strong,{children:"XXXXX"})," to the ",(0,s.jsx)(n.a,{href:"https://app.platerecognizer.com/service/snapshot-sdk/",children:"License Key"})," that we gave you."]}),"\n",(0,s.jsxs)(n.li,{children:["Change ",(0,s.jsx)(n.strong,{children:"YYYYY"})," to your ",(0,s.jsx)(n.a,{href:"https://app.platerecognizer.com/service/snapshot-sdk/",children:"Plate Recognizer Token"}),"."]}),"\n"]})]})]})}function m(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},65195(e,n,r){r.d(n,{A:()=>x});var a=r(96540),s=r(6342);function i(e){const n=e.map(e=>
1({...e,parentIndex:-1,children:[]})),r=Array(7).fill(-1);n.forEach((e,n)=>{const a=r.slice(2,e.level);e.parentIndex=Math.max(...a),r[e.level]=n});const a=[];return n.forEach(e=>{const{parentIndex:r,...s}=e;r>=0?n[r].children.push(s):a.push(s)}),a}function t({toc:e,minHeadingLevel:n,maxHeadingLevel:r}){return e.flatMap(e=>{const a=t({toc:e.children,minHeadingLevel:n,maxHeadingLevel:r});return function(e){return e.level>=n&&e.level<=r}(e)?[{...e,children:a}]:a})}function o(e){const n=e.getBoundingClientRect();return n.top===n.bottom?o(e.parentNode):n}function l(e,{anchorTopOffset:n}){const r=e.find(e=>o(e).top>=n);if(r){return function(e){return e.top>0&&e.bottom<window.innerHeight/2}(o(r))?r:e[e.indexOf(r)-1]??null}return e[e.length-1]??null}function d(){const e=(0,a.useRef)(0),{navbar:{hideOnScroll:n}}=(0,s.p)();return(0,a.useEffect)(()=>{e.current=n?0:document.querySelector(".navbar").clientHeight},[n]),e}function c(e){const n=(0,a.useRef)(void 0),r=d();(0,a.useEffect)(()=>{if(!e)return()=>{};const{linkClassName:a,linkActiveClassName:s,minHeadingLevel:i,maxHeadingLevel:t}=e;function o(){const e=function(e){return Array.from(document.getElementsByClassName(e))}(a),o=function({minHeadingLevel:e,maxHeadingLevel:n}){const r=[];for(let a=e;a<=n;a+=1)r.push(`h${a}.anchor`);return Array.from(document.querySelectorAll(r.join()))}({minHeadingLevel:i,maxHeadingLevel:t}),d=l(o,{anchorTopOffset:r.current}),c=e.find(e=>d&&d.id===function(e){return decodeURIComponent(e.href.substring(e.href.indexOf("#")+1))}(e));e.forEach(e=>{!function(e,r){r?(n.current&&n.current!==e&&n.current.classList.remove(s),e.classList.add(s),n.current=e):e.classList.remove(s)}(e,e===c)})}return document.addEventListener("scroll",o),document.addEventListener("resize",o),o(),()=>{document.removeEventListener("scroll",o),document.removeEventListener("resize",o)}},[e,r])}var h=r(28774),m=r(74848);function u({toc:e,className:n,linkClassName:r,isChild:a}){return e.length?(0,m.jsx)("ul",{className:a?void 0:n,children:e.map(e=>(0,m.jsxs)("li",{children:[(0,m.jsx)(h.A,{to:`#${e.id}`,className:r??void 0,dangerouslySetInnerHTML:{__html:e.value}}),(0,m.jsx)(u,{isChild:!0,toc:e.children,className:n,linkClassName:r})]},e.id))}):null}const p=a.memo(u);function x({toc:e,className:n="table-of-contents table-of-contents__left-border",linkClassName:r="table-of-contents__link",linkActiveClassName:o,minHeadingLevel:l,maxHeadingLevel:d,...h}){const u=(0,s.p)(),x=l??u.tableOfContents.minHeadingLevel,v=d??u.tableOfContents.maxHeadingLevel,j=function({toc:e,minHeadingLevel:n,maxHeadingLevel:r}){return(0,a.useMemo)(()=>t({toc:i(e),minHeadingLevel:n,maxHeadingLevel:r}),[e,n,r])}({toc:e,minHeadingLevel:x,maxHeadingLevel:v});return c((0,a.useMemo)(()=>{if(r&&o)return{linkClassName:r,linkActiveClassName:o,minHeadingLevel:x,maxHeadingLevel:v}},[r,o,x,v])),(0,m.jsx)(p,{toc:j,className:n,linkClassName:r,...h})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.