{"id":2052,"date":"2022-04-15T08:31:26","date_gmt":"2022-04-15T08:31:26","guid":{"rendered":"https:\/\/dreid.nl\/?p=2052"},"modified":"2022-04-15T08:31:26","modified_gmt":"2022-04-15T08:31:26","slug":"object-detection-with-yolo","status":"publish","type":"post","link":"https:\/\/dreid.nl\/?p=2052","title":{"rendered":"Object detection with YOLO"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/ultralytics\/yolov5\" target=\"_blank\" rel=\"noopener\">Yolo<\/a> is a well-known and popular object detection architecture. It is also very easy to use as things like model download and using various input sources are handled by the <em>detect.py<\/em> script. The <a href=\"https:\/\/dreid.nl\/?p=2048\">Tensorflow Object Detection API<\/a> could learn a thing or two from this&#8230; You can download everything from Github via git or by downloading a ZIP.<\/p>\n<p>For video output to work on Windows, you might need to install the <em>opencv-contrib-python<\/em> package via conda or pip. All other requirements are listed in requirements.txt &#8211; if you use Anaconda, you should try downloading them with <em>conda<\/em> first before resorting to <em>pip.<\/em><\/p>\n<p>What&#8217;s really fun with Yolo is that you can directly use your webcam for real-time object detection. You can e.g. do this with the high-resolution 5l6 model with this command:<\/p>\n<p><code>python detect.py --weights yolov5l6.pt --source 0 --nosave<\/code><\/p>\n<p>I ran into the issue that the webcam image size was stuck at 640&#215;640. Changing the default size in detect.py via<\/p>\n<p><code>parser.add_argument('--imgsz', '--img', '--img-size', nargs='+', type=int, default=[1280,720], help='inference size h,w')<\/code><\/p>\n<p>was not enough. You also need to edit datasets.py in the location where the video capture is started:<\/p>\n<p><code>cap = cv2.VideoCapture(s,cv2.CAP_DSHOW)<br \/>\ncap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)<br \/>\ncap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)<\/code><\/p>\n<p>Note that I&#8217;ve set 1920&#215;1080 here, but my built-in webcam is limited to 1280&#215;720 &#8211; hence the smaller default size in detect.py. You can up that to 1920&#215;1080 as well if you have a Full HD webcam.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yolo is a well-known and popular object detection architecture. It is also very easy to use as things like model download and using various input sources are handled by the detect.py script. The Tensorflow Object Detection API could learn a thing or two from this&#8230; You can download everything from Github via git or by [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[100],"tags":[112,111,127],"class_list":{"0":"post-2052","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-blog","7":"tag-image-processing","8":"tag-machine-learning","9":"tag-python","10":"czr-hentry"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Object detection with YOLO - DreiD BV<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dreid.nl\/?p=2052\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Object detection with YOLO - DreiD BV\" \/>\n<meta property=\"og:description\" content=\"Yolo is a well-known and popular object detection architecture. It is also very easy to use as things like model download and using various input sources are handled by the detect.py script. The Tensorflow Object Detection API could learn a thing or two from this&#8230; You can download everything from Github via git or by [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dreid.nl\/?p=2052\" \/>\n<meta property=\"og:site_name\" content=\"DreiD BV\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DreiDBV\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-15T08:31:26+00:00\" \/>\n<meta name=\"author\" content=\"Tobias\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Geschreven door\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tobias\" \/>\n\t<meta name=\"twitter:label2\" content=\"Verwachte leestijd\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minuut\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2052#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2052\"},\"author\":{\"name\":\"Tobias\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/#\\\/schema\\\/person\\\/724765ca445bdd176b5dfa6f0f432741\"},\"headline\":\"Object detection with YOLO\",\"datePublished\":\"2022-04-15T08:31:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2052\"},\"wordCount\":219,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/#organization\"},\"keywords\":[\"Image processing\",\"Machine Learning\",\"Python\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/dreid.nl\\\/?p=2052#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2052\",\"url\":\"https:\\\/\\\/dreid.nl\\\/?p=2052\",\"name\":\"Object detection with YOLO - DreiD BV\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/#website\"},\"datePublished\":\"2022-04-15T08:31:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2052#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/dreid.nl\\\/?p=2052\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/?p=2052#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dreid.nl\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Object detection with YOLO\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/#website\",\"url\":\"https:\\\/\\\/dreid.nl\\\/\",\"name\":\"DreiD BV\",\"description\":\"3D printen en meer\",\"publisher\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/dreid.nl\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"nl-NL\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/#organization\",\"name\":\"DreiD B.V.\",\"url\":\"https:\\\/\\\/dreid.nl\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"http:\\\/\\\/dreid.nl\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/cropped-logo-vierkant.png\",\"contentUrl\":\"http:\\\/\\\/dreid.nl\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/cropped-logo-vierkant.png\",\"width\":512,\"height\":512,\"caption\":\"DreiD B.V.\"},\"image\":{\"@id\":\"https:\\\/\\\/dreid.nl\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/DreiDBV\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dreid.nl\\\/#\\\/schema\\\/person\\\/724765ca445bdd176b5dfa6f0f432741\",\"name\":\"Tobias\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g\",\"caption\":\"Tobias\"},\"url\":\"https:\\\/\\\/dreid.nl\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Object detection with YOLO - DreiD BV","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dreid.nl\/?p=2052","og_locale":"nl_NL","og_type":"article","og_title":"Object detection with YOLO - DreiD BV","og_description":"Yolo is a well-known and popular object detection architecture. It is also very easy to use as things like model download and using various input sources are handled by the detect.py script. The Tensorflow Object Detection API could learn a thing or two from this&#8230; You can download everything from Github via git or by [&hellip;]","og_url":"https:\/\/dreid.nl\/?p=2052","og_site_name":"DreiD BV","article_publisher":"https:\/\/www.facebook.com\/DreiDBV","article_published_time":"2022-04-15T08:31:26+00:00","author":"Tobias","twitter_card":"summary_large_image","twitter_misc":{"Geschreven door":"Tobias","Verwachte leestijd":"1 minuut"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dreid.nl\/?p=2052#article","isPartOf":{"@id":"https:\/\/dreid.nl\/?p=2052"},"author":{"name":"Tobias","@id":"https:\/\/dreid.nl\/#\/schema\/person\/724765ca445bdd176b5dfa6f0f432741"},"headline":"Object detection with YOLO","datePublished":"2022-04-15T08:31:26+00:00","mainEntityOfPage":{"@id":"https:\/\/dreid.nl\/?p=2052"},"wordCount":219,"commentCount":0,"publisher":{"@id":"https:\/\/dreid.nl\/#organization"},"keywords":["Image processing","Machine Learning","Python"],"articleSection":["Blog"],"inLanguage":"nl-NL","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dreid.nl\/?p=2052#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dreid.nl\/?p=2052","url":"https:\/\/dreid.nl\/?p=2052","name":"Object detection with YOLO - DreiD BV","isPartOf":{"@id":"https:\/\/dreid.nl\/#website"},"datePublished":"2022-04-15T08:31:26+00:00","breadcrumb":{"@id":"https:\/\/dreid.nl\/?p=2052#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dreid.nl\/?p=2052"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dreid.nl\/?p=2052#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dreid.nl\/"},{"@type":"ListItem","position":2,"name":"Object detection with YOLO"}]},{"@type":"WebSite","@id":"https:\/\/dreid.nl\/#website","url":"https:\/\/dreid.nl\/","name":"DreiD BV","description":"3D printen en meer","publisher":{"@id":"https:\/\/dreid.nl\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dreid.nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"nl-NL"},{"@type":"Organization","@id":"https:\/\/dreid.nl\/#organization","name":"DreiD B.V.","url":"https:\/\/dreid.nl\/","logo":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/dreid.nl\/#\/schema\/logo\/image\/","url":"http:\/\/dreid.nl\/wp-content\/uploads\/2017\/11\/cropped-logo-vierkant.png","contentUrl":"http:\/\/dreid.nl\/wp-content\/uploads\/2017\/11\/cropped-logo-vierkant.png","width":512,"height":512,"caption":"DreiD B.V."},"image":{"@id":"https:\/\/dreid.nl\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DreiDBV"]},{"@type":"Person","@id":"https:\/\/dreid.nl\/#\/schema\/person\/724765ca445bdd176b5dfa6f0f432741","name":"Tobias","image":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/secure.gravatar.com\/avatar\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/da384b41c29915cbc57151669bfd69215048a0d4cebed631ab35a6f893826870?s=96&d=mm&r=g","caption":"Tobias"},"url":"https:\/\/dreid.nl\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/posts\/2052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dreid.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2052"}],"version-history":[{"count":2,"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/posts\/2052\/revisions"}],"predecessor-version":[{"id":2194,"href":"https:\/\/dreid.nl\/index.php?rest_route=\/wp\/v2\/posts\/2052\/revisions\/2194"}],"wp:attachment":[{"href":"https:\/\/dreid.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dreid.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dreid.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}