{"action":"opened","issue":{"url":"https://api.github.com/repos/mshabunin/test2/issues/384","labels_url":"https://api.github.com/repos/mshabunin/test2/issues/384/labels{/name}","comments_url":"https://api.github.com/repos/mshabunin/test2/issues/384/comments","events_url":"https://api.github.com/repos/mshabunin/test2/issues/384/events","html_url":"https://github.com/mshabunin/test2/issues/384","id":95187021,"number":384,"title":"Android JNI cv::findContours causes memory corruption.","user":{"login":"mshabunin","id":3304494,"avatar_url":"https://avatars.githubusercontent.com/u/3304494?v=3","gravatar_id":"","url":"https://api.github.com/users/mshabunin","html_url":"https://github.com/mshabunin","followers_url":"https://api.github.com/users/mshabunin/followers","following_url":"https://api.github.com/users/mshabunin/following{/other_user}","gists_url":"https://api.github.com/users/mshabunin/gists{/gist_id}","starred_url":"https://api.github.com/users/mshabunin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mshabunin/subscriptions","organizations_url":"https://api.github.com/users/mshabunin/orgs","repos_url":"https://api.github.com/users/mshabunin/repos","events_url":"https://api.github.com/users/mshabunin/events{/privacy}","received_events_url":"https://api.github.com/users/mshabunin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mshabunin/test2/labels/affected:%202.4","name":"affected: 2.4","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/auto-transferred","name":"auto-transferred","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/category:%20android","name":"category: android","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/priority:%20normal","name":"priority: normal","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/status:%20open","name":"status: open","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/target:%20-","name":"target: -","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-15T13:06:23Z","updated_at":"2015-07-15T13:06:23Z","closed_at":null,"body":"Converted from http://code.opencv.org/issues/3541\r\n```\n|| by Danilo Medic on 2014-02-13 01:40\n|| Status: Open\n|| Priority: Normal\n|| Affected: 2.4.8 (latest release)\n|| Target: -\n|| Category: android\n|| Tracker: bug\n```\n\nAndroid JNI cv::findContours causes memory corruption.\n-----------\n```\nI have developed a payment slip scanner that is already being used in\nindustry on the iOS platform.  \nMy company is now going to support android platform as well so I had to\nmake cross platform solution.\n\nI have chosen to implement all the logic in C++ and then to import this\ncross platform code to java JNI (android) and objective c (iOS)\n(platform specific) wrappers.\n\nIt turns out that my android project occasionally and\nnondeterministically fails while iOS version works without no problem at\nall.  \nAfter a lot of code elimination and debugging I have founded out that\nthis memory corruption only occurs when i use cv::findContours function.\n\nCan you please tell me if there are already some reported issues with\nthis function?\n\n(OpenCV-2.4.8, ndk-r8e, Mac OSX)\n```\n\nHistory\n-------\n##### by Alexander Smorkalov on 2014-02-13 01:54\n```\nThank you for the issue report. Can you provide some small reproducer\nthat demonstrates the fault? It will be very helpful for OpenCV team.\n-   Target version set to 2.4.9\n-   Status changed from New to Incomplete\n```\n##### by Danilo Medic on 2014-02-13 02:36\n```\nThank you for the fast response.\n\nThe smallest code base that I managed to reproduce this issue with was:\n\ncv::Mat inputGrayImage = ... ;if(inputGrayImage.type() == CV_8UC1) {cv::Mat thresholdedImage(inputGrayImage.rows, inputGrayImage.cols, CV_8UC1);cv::adaptiveThreshold(inputGrayImage, thresholdedImage, 255, CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY_INV, constA, constB);std::vector<std::vector<cv::Point> > contours;cv::Mat copy = thresholdedImage.clone();cv::findContours(copy , contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);http://code.opencv.org/issues/3541/edit}\n\nI just want to emphasize that it took me like 30 minutes to reproduce\nthe problem with this code...\n\nAny suggestion?\n```\n##### by Danilo Medic on 2014-03-10 12:55\n```\nI still have not fixed the problem.   \nDo you guys have any suggestions? :(\n```\n##### by Alexander Smorkalov on 2014-04-01 11:22\n```\n-   Target version deleted (2.4.9)\n-   Status changed from Incomplete to Open\n```"}}