{"id":12240,"date":"2022-09-30T04:29:30","date_gmt":"2022-09-29T22:59:30","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/"},"modified":"2022-09-30T04:29:30","modified_gmt":"2022-09-29T22:59:30","slug":"solved-what-is-this-bit-of-code-doing","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/","title":{"rendered":"[Solved] What is this bit of code doing?"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-35505537\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"35505537\" data-parentid=\"35504329\" data-score=\"0\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>self.tracks seems to be an (n,2) <code>list<\/code>. The outer loop takes each of these values, turns them two by two into integers <code>x<\/code> and <code>y<\/code>, then performs a function\/method <code>cv2.circle<\/code> with an object <code>mask<\/code> and several other parameters. <code>container[-1]<\/code> indicates that you want the value of the last index of <code>container<\/code>.<\/p>\n<p>The values of the function\/method <code>goodFeaturesToTrack<\/code> are assigned to <code>p<\/code>(which seem to be an array or <code>None<\/code>). <code>**<\/code> indicates that <code>feature_params<\/code> is a dictionary of parameters(if a function is defined as <code>myfunc(a,b=2,c=3,d=5)<\/code> you could change some of these values for that<br \/>\nfunction call by calling <code>myfunc(\"value of a\",**mydict)<\/code> with mydict being a dictionary containing zero or more of the optional variables a, b and c (eg <code>mydict={'b':8,<\/code>d<code>:0}<\/code> would change b and d from their default values to 8 and 0 respectively.<\/p>\n<p>a new (float-valued) <code>x<\/code> and <code>y<\/code> are then extracted from a reshape of p and appended back to the list <code>self.tracks<\/code> as a pair. <\/p>\n<p>The -1 in the reshape indicate that you dont care about how long the given axis as long as the other axis has the right shape. eg. an array of 10 values would be reshaped to (5,2) a (4,4) would be reshaped to (8,2) etc. This could have been found by searching for <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/docs.scipy.org\/doc\/numpy\/reference\/generated\/numpy.reshape.html#numpy.reshape\"><code>numpy.reshape<\/code><\/a>:<\/p>\n<blockquote>\n<p>newshape : int or tuple of ints<\/p>\n<p>The new shape should be compatible with the original shape. If an &gt;integer, then the result will be a 1-D array of that length. One shape &gt;dimension can be -1. In this case, the value is inferred from the length of &gt;the array and remaining dimensions.<\/p>\n<\/blockquote><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\"><\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved What is this bit of code doing? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] self.tracks seems to be an (n,2) list. The outer loop takes each of these values, turns them two by two into integers x and y, then performs a function\/method cv2.circle with an object mask and several other parameters. container[-1] indicates that you want the value of the last index of container. The values of &#8230; <a title=\"[Solved] What is this bit of code doing?\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/\" aria-label=\"More on [Solved] What is this bit of code doing?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[2253,581,1087,349,482],"class_list":["post-12240","post","type-post","status-publish","format-standard","hentry","category-solved","tag-computer-vision","tag-numpy","tag-opencv","tag-python","tag-python-3-x"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] What is this bit of code doing? - JassWeb<\/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:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] What is this bit of code doing? - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] self.tracks seems to be an (n,2) list. The outer loop takes each of these values, turns them two by two into integers x and y, then performs a function\/method cv2.circle with an object mask and several other parameters. container[-1] indicates that you want the value of the last index of container. The values of ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-29T22:59:30+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] What is this bit of code doing?\",\"datePublished\":\"2022-09-29T22:59:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/\"},\"wordCount\":262,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"computer-vision\",\"numpy\",\"opencv\",\"python\",\"python-3.x\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/\",\"name\":\"[Solved] What is this bit of code doing? - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-09-29T22:59:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] What is this bit of code doing?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] What is this bit of code doing? - JassWeb","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:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] What is this bit of code doing? - JassWeb","og_description":"[ad_1] self.tracks seems to be an (n,2) list. The outer loop takes each of these values, turns them two by two into integers x and y, then performs a function\/method cv2.circle with an object mask and several other parameters. container[-1] indicates that you want the value of the last index of container. The values of ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/","og_site_name":"JassWeb","article_published_time":"2022-09-29T22:59:30+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] What is this bit of code doing?","datePublished":"2022-09-29T22:59:30+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/"},"wordCount":262,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["computer-vision","numpy","opencv","python","python-3.x"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/","url":"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/","name":"[Solved] What is this bit of code doing? - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-09-29T22:59:30+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-what-is-this-bit-of-code-doing\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] What is this bit of code doing?"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/12240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=12240"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/12240\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=12240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=12240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=12240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}