{"id":13443117,"url":"https://github.com/JetsonHacksNano/CSI-Camera","last_synced_at":"2025-03-20T16:30:25.277Z","repository":{"id":43753914,"uuid":"178633534","full_name":"JetsonHacksNano/CSI-Camera","owner":"JetsonHacksNano","description":"Simple example of using a CSI-Camera (like the Raspberry Pi Version 2 camera) with the NVIDIA Jetson Developer Kit","archived":false,"fork":false,"pushed_at":"2023-05-25T00:05:26.000Z","size":48,"stargazers_count":858,"open_issues_count":27,"forks_count":295,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-03-20T11:09:02.833Z","etag":null,"topics":["csi-camera","jetson-nano","jetson-xavier-nx","opencv","opencv-python","rpi-camera"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JetsonHacksNano.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-03-31T02:28:21.000Z","updated_at":"2025-03-20T06:30:41.000Z","dependencies_parsed_at":"2022-09-07T04:23:55.567Z","dependency_job_id":"7c4663de-00a9-423d-bba2-fc3c86707c0a","html_url":"https://github.com/JetsonHacksNano/CSI-Camera","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetsonHacksNano%2FCSI-Camera","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetsonHacksNano%2FCSI-Camera/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetsonHacksNano%2FCSI-Camera/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JetsonHacksNano%2FCSI-Camera/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JetsonHacksNano","download_url":"https://codeload.github.com/JetsonHacksNano/CSI-Camera/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244649672,"owners_count":20487467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csi-camera","jetson-nano","jetson-xavier-nx","opencv","opencv-python","rpi-camera"],"created_at":"2024-07-31T03:01:56.341Z","updated_at":"2025-03-20T16:30:25.253Z","avatar_url":"https://github.com/JetsonHacksNano.png","language":"Python","readme":"# CSI-Camera\nSimple example of using a MIPI-CSI(2) Camera (like the Raspberry Pi Version 2 camera) with the NVIDIA Jetson Developer Kits with CSI camera ports. This includes the recent Jetson Nano and Jetson Xavier NX.  This is support code for the article on JetsonHacks: https://wp.me/p7ZgI9-19v\n\nFor the Nanos and Xavier NX, the camera should be installed in the MIPI-CSI Camera Connector on the carrier board. The pins on the camera ribbon should face the Jetson module, the tape stripe faces outward.\n\nSome Jetson developer kits have two CSI camera slots. You can use the sensor_mode attribute with the GStreamer nvarguscamerasrc element to specify which camera. Valid values are 0 or 1 (the default is 0 if not specified), i.e.\n\n```\nnvarguscamerasrc sensor_id=0\n```\n\nTo test the camera:\n\n```\n# Simple Test\n#  Ctrl^C to exit\n# sensor_id selects the camera: 0 or 1 on Jetson Nano B01\n$ gst-launch-1.0 nvarguscamerasrc sensor_id=0 ! nvoverlaysink\n\n# More specific - width, height and framerate are from supported video modes\n# Example also shows sensor_mode parameter to nvarguscamerasrc\n# See table below for example video modes of example sensor\n$ gst-launch-1.0 nvarguscamerasrc sensor_id=0 ! \\\n   'video/x-raw(memory:NVMM),width=1920, height=1080, framerate=30/1' ! \\\n   nvvidconv flip-method=0 ! 'video/x-raw,width=960, height=540' ! \\\n   nvvidconv ! nvegltransform ! nveglglessink -e\n```\n\nNote: The cameras may report differently than show below. You can use the simple gst-launch example above to determine the camera modes that are reported by the sensor you are using. \n```\nGST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;\n```\n\nAlso, the display transform may be sensitive to width and height (in the above example, width=960, height=540). If you experience issues, check to see if your display width and height is the same ratio as the camera frame size selected (In the above example, 960x540 is 1/4 the size of 1920x1080).\n\n\n## Samples\n\n\n### simple_camera.py\nsimple_camera.py is a Python script which reads from the camera and displays the frame to a window on the screen using OpenCV:\n```\n$ python simple_camera.py\n```\n### face_detect.py\n\nface_detect.py is a python script which reads from the camera and uses  Haar Cascades to detect faces and eyes:\n```\n$ python face_detect.py\n```\nHaar Cascades is a machine learning based approach where a cascade function is trained from a lot of positive and negative images. The function is then used to detect objects in other images. \n\nSee: https://docs.opencv.org/3.3.1/d7/d8b/tutorial_py_face_detection.html \n\n\n### dual_camera.py\nNote: You will need install numpy for the Dual Camera Python example to work:\n```\n$ pip3 install numpy\n```\nThis example is for the newer Jetson boards (Jetson Nano, Jetson Xavier NX) with two CSI-MIPI camera ports. This is a simple Python program which reads both CSI cameras and displays them in one window. The window is 1920x540. For performance, the script uses a separate thread for reading each camera image stream. To run the script:\n\n```\n$ python3 dual_camera.py\n```\n\n### simple_camera.cpp\nThe last example is a simple C++ program which reads from the camera and displays to a window on the screen using OpenCV:\n\n```\n$ g++ -std=c++11 -Wall -I/usr/lib/opencv -I/usr/include/opencv4 simple_camera.cpp -L/usr/lib -lopencv_core -lopencv_highgui -lopencv_videoio -o simple_camera\n\n$ ./simple_camera\n```\nThis program is a simple outline, and does not handle needed error checking well. For better C++ code, use https://github.com/dusty-nv/jetson-utils\n\n\u003ch2\u003eNotes\u003c/h2\u003e\n\n\u003ch3\u003eCamera Image Formats\u003c/h3\u003e\nYou can use v4l2-ctl to determine the camera capabilities. v4l2-ctl is in the v4l-utils:\n```\n$ sudo apt-get install v4l-utils\n```\nFor the Raspberry Pi V2 camera, a typical output is (assuming the camera is /dev/video0):\n\n```\n$ v4l2-ctl --list-formats-ext\nioctl: VIDIOC_ENUM_FMT\n\tIndex       : 0\n\tType        : Video Capture\n\tPixel Format: 'RG10'\n\tName        : 10-bit Bayer RGRG/GBGB\n\t\tSize: Discrete 3280x2464\n\t\t\tInterval: Discrete 0.048s (21.000 fps)\n\t\tSize: Discrete 3280x1848\n\t\t\tInterval: Discrete 0.036s (28.000 fps)\n\t\tSize: Discrete 1920x1080\n\t\t\tInterval: Discrete 0.033s (30.000 fps)\n\t\tSize: Discrete 1280x720\n\t\t\tInterval: Discrete 0.017s (60.000 fps)\n\t\tSize: Discrete 1280x720\n\t\t\tInterval: Discrete 0.017s (60.000 fps)\n```\n\n\u003ch3\u003eGStreamer Parameter\u003c/h3\u003e\nFor the GStreamer pipeline, the nvvidconv flip-method parameter can rotate/flip the image. This is useful when the mounting of the camera is of a different orientation than the default.\n\n```\n\nflip-method         : video flip methods\n                        flags: readable, writable, controllable\n                        Enum \"GstNvVideoFlipMethod\" Default: 0, \"none\"\n                           (0): none             - Identity (no rotation)\n                           (1): counterclockwise - Rotate counter-clockwise 90 degrees\n                           (2): rotate-180       - Rotate 180 degrees\n                           (3): clockwise        - Rotate clockwise 90 degrees\n                           (4): horizontal-flip  - Flip horizontally\n                           (5): upper-right-diagonal - Flip across upper right/lower left diagonal\n                           (6): vertical-flip    - Flip vertically\n                           (7): upper-left-diagonal - Flip across upper left/low\n```\n\n\u003ch2\u003eOpenCV and Python\u003c/h2\u003e\nStarting with L4T 32.2.1 / JetPack 4.2.2, GStreamer support is built in to OpenCV.\nThe OpenCV version is 3.3.1 for those versions. Please note that if you are using\nearlier versions of OpenCV (most likely installed from the Ubuntu repository), you\nwill get 'Unable to open camera' errors.\n\u003cbr\u003e\nIf you can open the camera in GStreamer from the command line, and have issues opening the camera in Python, check the OpenCV version. \n\n```\n\u003e\u003e\u003ecv2.__version__\n```\n\n\u003ch2\u003eRelease Notes\u003c/h2\u003e\n\nv3.2 Release January, 2022\n* Add Exception handling to Python code\n* Faster GStreamer pipelines, better performance\n* Better naming of variables, simplification\n* Remove Instrumented examples\n* L4T 32.6.1 (JetPack 4.5)\n* OpenCV 4.4.1\n* Python3\n* Tested on Jetson Nano B01, Jetson Xavier NX\n* Tested with Raspberry Pi V2 cameras\n\n\nv3.11 Release April, 2020\n* Release both cameras in dual camera example (bug-fix)\n\nv3.1 Release March, 2020\n* L4T 32.3.1 (JetPack 4.3)\n* OpenCV 4.1.1\n* Tested on Jetson Nano B01\n* Tested with Raspberry Pi v2 cameras\n\nv3.0 December 2019\n* L4T 32.3.1\n* OpenCV 4.1.1.\n* Tested with Raspberry Pi v2 camera\n\nv2.0 Release September, 2019\n* L4T 32.2.1 (JetPack 4.2.2)\n* OpenCV 3.3.1\n* Tested on Jetson Nano\n\nInitial Release (v1.0) March, 2019\n* L4T 32.1.0 (JetPack 4.2)\n* Tested on Jetson Nano\n\n\n","funding_links":[],"categories":["Python","CSI Camera"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJetsonHacksNano%2FCSI-Camera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJetsonHacksNano%2FCSI-Camera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJetsonHacksNano%2FCSI-Camera/lists"}