{"action":"opened","issue":{"url":"https://api.github.com/repos/mshabunin/test2/issues/67","labels_url":"https://api.github.com/repos/mshabunin/test2/issues/67/labels{/name}","comments_url":"https://api.github.com/repos/mshabunin/test2/issues/67/comments","events_url":"https://api.github.com/repos/mshabunin/test2/issues/67/events","html_url":"https://github.com/mshabunin/test2/issues/67","id":95662563,"number":67,"title":"Problem Accessing Histogram Elements in Android Version of OpenCV","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/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:%20java%20bindings","name":"category: java bindings","color":"ededed"},{"url":"https://api.github.com/repos/mshabunin/test2/labels/priority:%20normal","name":"priority: normal","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-17T14:05:58Z","updated_at":"2015-07-17T14:05:58Z","closed_at":null,"body":"Transferred from http://code.opencv.org/issues/1447\r\n```\n|| soriel - on 2011-10-25 21:26\n|| Priority: Normal\n|| Affected: None\n|| Category: java bindings\n|| Tracker: Bug\n|| Difficulty: None\n|| PR: None\n|| Platform: None / None\n```\n\nProblem Accessing Histogram Elements in Android Version of OpenCV\n-----------\n```\nI need to access the elements of a @Mat@ that is created by @Mat.calcHist@ call. However, it appears that @Mat.get@ does not return the correct set of values. Here is an example:\r\n\r\n<pre><code class=\"java\">\r\npublic void createHistogram(Bitmap img) {\r\n\r\n   Mat hist = new Mat();\r\n\r\n   Mat mat_img = Utils.bitmapToMat(img);\r\n\r\n   ArrayList<Mat> images = new ArrayList<Mat>();\r\n   List<Integer> channels = new ArrayList<Integer>();\r\n   List<Integer> histSize = new ArrayList<Integer>();\r\n   List<Float> ranges = new ArrayList<Float>();\r\n\r\n   images.add(mat_img);\r\n\r\n   channels.add(0);\r\n   channels.add(1);\r\n   channels.add(2);\r\n\r\n   // 10x10x10\r\n   histSize.add(10);\r\n   histSize.add(10);\r\n   histSize.add(10);\r\n   ranges.add(0.0f);\r\n   ranges.add(256.0f);\r\n   ranges.add(0.0f);\r\n   ranges.add(256.0f);\r\n   ranges.add(0.0f);\r\n   ranges.add(256.0f);\r\n\r\n   Imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges, false);\r\n\r\n   float[] data = new floatr10;\r\n   StringBuffer temp = new StringBuffer();\r\n     for (int r = 0; r < 10; r++)\r\n       for (int g = 0; g < 10; g++){\r\n         hist.get(r, g, data);\r\n         for (int b = 0; b < 10; b++)\r\n         temp.append(\",\").append(data[b])\r\n       }\r\n   Log.i(TAG, Core.sumElems(hist)); // Prints out the number of pixels in the image (correct)\r\n   Log.i(TAG, temp.toString()); // Prints out all 0s (Incorrect)\r\n}\r\n</code></pre>\n```\n\nHistory\n-------\n##### Kirill Kornyakov on 2012-02-14 15:16\n```\nAndrey, could you please look into this in the background.\n-   Target version set to 2.4.0\n-   Priority changed from High to Normal\n-   Assignee changed from Kirill Kornyakov to Andrey Pavlenko\n```\n##### Andrey Kamaev on 2012-02-25 12:23\n```\n-   Description changed from I need to access the elements of a Mat that\n    is created by Mat.calcHist call. ... to I need to access the\n    elements of a @Mat@ that is created by @Mat.calcHist@ ca... More\n```\n##### Alexander Shishkov on 2012-03-21 11:38\n```\n-   Target version deleted (2.4.0)\n```\n##### Alexander Shishkov on 2012-03-25 20:43\n```\n-   Assignee deleted (Andrey Pavlenko)\n```\n##### Andrey Pavlenko on 2012-03-26 08:26\n```\n-   Assignee set to Andrey Pavlenko\n```\n##### Andrey Pavlenko on 2012-04-02 12:32\n```\nMat::get() and Mat::put() don't work for Mat-s of more than 2 dimensions.\n-   Target version set to 2.4.0\n```\n##### Andrey Pavlenko on 2012-04-26 11:58\n```\nThe support of 3+ dimensional Mat-s in Java API will be done after 2.4 release.\nCurrently as a workaround I suggest use calcHist() for 1 or 2 channels only, e.g.:\n<pre> <code class=\"java\">\npublic void testCalcHistListOfMatListOfIntegerMatMatListOfIntegerListOfFloat3D() {\n    List<Mat> images = Arrays.asList(rgbLena);\n    \n    Mat hist3D = new Mat();\n    List<Mat> histList = Arrays.asList( new Mat[] {new Mat(), new Mat(), new Mat()} );\n    \n    MatOfInt histSize = new MatOfInt(10);\n    MatOfFloat ranges = new MatOfFloat(0f, 256f);\n    \n    for(int i=0; i<rgbLena.channels(); i++)\n    {\n        Imgproc.calcHist(images, new MatOfInt(i), new Mat(), histList.get(i), histSize, ranges);\n\n        assertEquals(10, histList.get(i).checkVector(1));\n    }\n    \n    Core.merge(histList, hist3D);\n\n    assertEquals(CvType.CV_32FC3, hist3D.type());\n    assertEquals(10, hist3D.checkVector(3));\n    \n    Mat truth = new Mat(10, 1, CvType.CV_32FC3);\n    truth.put(0, 0,\n    \t\t 0, 24870, 0,\n    \t\t 1863, 31926, 1,\n    \t\t 56682, 37677, 2260,\n    \t\t 77278, 44751, 32436,\n    \t\t 69397, 41343, 18526,\n    \t\t 27180, 40407, 18658,\n    \t\t 21101, 15993, 32042,\n    \t\t 8343, 18585, 47786,\n    \t\t 300, 6567, 80988,\n    \t\t 0, 25, 29447\n    \t\t);\n    \n    assertMatEqual(truth, hist3D, EPS);\n}\n</code></pre>\n-   Target version deleted (2.4.0)\n```\n##### Andrey Pavlenko on 2012-06-20 08:15\n```\n-   Category changed from android to java bindings\n```"}}