{"action":"created","issue":{"url":"https://api.github.com/repos/opencv/opencv/issues/11765","repository_url":"https://api.github.com/repos/opencv/opencv","labels_url":"https://api.github.com/repos/opencv/opencv/issues/11765/labels{/name}","comments_url":"https://api.github.com/repos/opencv/opencv/issues/11765/comments","events_url":"https://api.github.com/repos/opencv/opencv/issues/11765/events","html_url":"https://github.com/opencv/opencv/issues/11765","id":332361324,"node_id":"MDU6SXNzdWUzMzIzNjEzMjQ=","number":11765,"title":"contourArea does not produce a correct number","user":{"login":"wagenrace","id":15228140,"node_id":"MDQ6VXNlcjE1MjI4MTQw","avatar_url":"https://avatars1.githubusercontent.com/u/15228140?v=4","gravatar_id":"","url":"https://api.github.com/users/wagenrace","html_url":"https://github.com/wagenrace","followers_url":"https://api.github.com/users/wagenrace/followers","following_url":"https://api.github.com/users/wagenrace/following{/other_user}","gists_url":"https://api.github.com/users/wagenrace/gists{/gist_id}","starred_url":"https://api.github.com/users/wagenrace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wagenrace/subscriptions","organizations_url":"https://api.github.com/users/wagenrace/orgs","repos_url":"https://api.github.com/users/wagenrace/repos","events_url":"https://api.github.com/users/wagenrace/events{/privacy}","received_events_url":"https://api.github.com/users/wagenrace/received_events","type":"User","site_admin":false},"labels":[{"id":9731374,"node_id":"MDU6TGFiZWw5NzMxMzc0","url":"https://api.github.com/repos/opencv/opencv/labels/question%20(invalid)","name":"question (invalid)","color":"000000","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-14T11:27:07Z","updated_at":"2018-06-14T11:46:48Z","closed_at":null,"author_association":"NONE","body":"##### System information (version)\r\n\r\n- OpenCV => 3.3.1 (python)\r\n- Operating System / Platform => Windows 10 64 Bit\r\n- Compiler => Visual Studio 2017\r\n\r\n##### Detailed description\r\n\r\nI had created 2 boxes both with an area of 500.000 pixels but with different dimensions. Using OpenCV findContours I got the contours, but calculating the area of these boxes resulted in 49551 and 49401.\r\nThe contours where correctly detected.\r\n\r\nThe first contour is 200 by 250 and gives a result of 49.551 (199 * 249?).\r\n\r\nThe second contour is 100 by 500 and gives a result of 49.401 (99 * 499?)\r\n\r\nMy hypothesis is the (upper or bottom) and (left  or right) border is not taken in to account.\r\n\r\n##### Steps to reproduce\r\n`import cv2\r\nimport numpy as np\r\n\r\ncontour1 = np.array([[[  0,   0]],\r\n                     [[  0, 199]],\r\n                     [[249, 199]],\r\n                     [[249,   0]]], dtype=np.int32)\r\n\r\ncontour2 = np.array([[[  0,   0]],\r\n                     [[  0, 99]],\r\n                     [[499, 99]],\r\n                     [[499,   0]]], dtype=np.int32)\r\n\r\nprint(\"contour 1, 200 by 250 has size\", cv2.contourArea(contour1))\r\nprint(\"contour 2, 100 by 500 has size\", cv2.contourArea(contour2))`\r\n\r\n###### PS\r\n- I do not know if the problem is also present in C++\r\n- The number is close to the correct answer but becomes a problem with smaller contours (a 10x10 square is off by 19%)"},"comment":{"url":"https://api.github.com/repos/opencv/opencv/issues/comments/397266305","html_url":"https://github.com/opencv/opencv/issues/11765#issuecomment-397266305","issue_url":"https://api.github.com/repos/opencv/opencv/issues/11765","id":397266305,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NzI2NjMwNQ==","user":{"login":"wagenrace","id":15228140,"node_id":"MDQ6VXNlcjE1MjI4MTQw","avatar_url":"https://avatars1.githubusercontent.com/u/15228140?v=4","gravatar_id":"","url":"https://api.github.com/users/wagenrace","html_url":"https://github.com/wagenrace","followers_url":"https://api.github.com/users/wagenrace/followers","following_url":"https://api.github.com/users/wagenrace/following{/other_user}","gists_url":"https://api.github.com/users/wagenrace/gists{/gist_id}","starred_url":"https://api.github.com/users/wagenrace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wagenrace/subscriptions","organizations_url":"https://api.github.com/users/wagenrace/orgs","repos_url":"https://api.github.com/users/wagenrace/repos","events_url":"https://api.github.com/users/wagenrace/events{/privacy}","received_events_url":"https://api.github.com/users/wagenrace/received_events","type":"User","site_admin":false},"created_at":"2018-06-14T11:46:48Z","updated_at":"2018-06-14T11:46:48Z","author_association":"NONE","body":"Why isn't this a bug? An outcome of a function what is not correct is a bug not a question, right?\r\n\r\nrepresent a rectangle 1x1 should be a single pixels. What for some reason gives a correct output of 1"}}
{"actor":{"display_login":"wagenrace"}}