{"id":53,"date":"2020-07-13T22:46:28","date_gmt":"2020-07-14T03:46:28","guid":{"rendered":"http:\/\/www.project4fun.com\/?p=53"},"modified":"2020-07-13T22:46:29","modified_gmt":"2020-07-14T03:46:29","slug":"opencvwebcamjetson-xavier","status":"publish","type":"post","link":"http:\/\/www.project4fun.com\/index.php\/2020\/07\/13\/opencvwebcamjetson-xavier\/","title":{"rendered":"OpenCV+WebCAM+Jetson Xavier"},"content":{"rendered":"\n<p>Install  v4l-utils with this command:-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install v4l-utils<\/code><\/pre>\n\n\n\n<p>Verify WebCAM<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1021\" height=\"1024\" src=\"http:\/\/www.project4fun.com\/wp-content\/uploads\/2020\/07\/Capture-1021x1024.jpg\" alt=\"\" class=\"wp-image-54\" srcset=\"http:\/\/www.project4fun.com\/wp-content\/uploads\/2020\/07\/Capture-1021x1024.jpg 1021w, http:\/\/www.project4fun.com\/wp-content\/uploads\/2020\/07\/Capture-150x150.jpg 150w, http:\/\/www.project4fun.com\/wp-content\/uploads\/2020\/07\/Capture-479x480.jpg 479w, http:\/\/www.project4fun.com\/wp-content\/uploads\/2020\/07\/Capture-768x770.jpg 768w, http:\/\/www.project4fun.com\/wp-content\/uploads\/2020\/07\/Capture.jpg 1105w\" sizes=\"(max-width: 1021px) 100vw, 1021px\" \/><\/figure>\n\n\n\n<p>Create python program with width and height from v4l2-ctl result.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import cv2\nprint(cv2.__version__)\nwidth=640\nheight=480\nflip=2\n#camSet='nvarguscamerasrc sensor-id=0 ! video\/x-raw(memory:NVMM), width=3264, height=2464, framerate=21\/1,format=NV12 ! nvvidconv flip-method='+str(flip)+' ! video\/x-raw, width='+str(width)+', height='+str(height)+', format=BGRx ! videoconvert ! video\/x-raw, format=BGR ! appsink'\ncamSet ='v4l2src device=\/dev\/video0 ! video\/x-raw,width='+str(width)+',height='+str(height)+',framerate=24\/1 ! videoconvert ! appsink'\ncam=cv2.VideoCapture(camSet)\nwhile True:\n    _, frame = cam.read()\n    cv2.imshow('myCam',frame)\n    cv2.moveWindow('myCam',0,0)\n    if cv2.waitKey(1)==ord('q'):\n        break\ncam.release()\ncv2.destroyAllWindows()\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Install v4l-utils with this command:- Verify WebCAM Create python program with width and height from v4l2-ctl result.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.project4fun.com\/index.php\/wp-json\/wp\/v2\/posts\/53"}],"collection":[{"href":"http:\/\/www.project4fun.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.project4fun.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.project4fun.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.project4fun.com\/index.php\/wp-json\/wp\/v2\/comments?post=53"}],"version-history":[{"count":1,"href":"http:\/\/www.project4fun.com\/index.php\/wp-json\/wp\/v2\/posts\/53\/revisions"}],"predecessor-version":[{"id":55,"href":"http:\/\/www.project4fun.com\/index.php\/wp-json\/wp\/v2\/posts\/53\/revisions\/55"}],"wp:attachment":[{"href":"http:\/\/www.project4fun.com\/index.php\/wp-json\/wp\/v2\/media?parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.project4fun.com\/index.php\/wp-json\/wp\/v2\/categories?post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.project4fun.com\/index.php\/wp-json\/wp\/v2\/tags?post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}