{"action":"created","issue":{"url":"https://api.github.com/repos/bytedeco/javacv/issues/150","labels_url":"https://api.github.com/repos/bytedeco/javacv/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/bytedeco/javacv/issues/150/comments","events_url":"https://api.github.com/repos/bytedeco/javacv/issues/150/events","html_url":"https://github.com/bytedeco/javacv/issues/150","id":76471067,"number":150,"title":"Error when convert BufferedImage to IplImage !","user":{"login":"henriquem","id":5496634,"avatar_url":"https://avatars.githubusercontent.com/u/5496634?v=3","gravatar_id":"","url":"https://api.github.com/users/henriquem","html_url":"https://github.com/henriquem","followers_url":"https://api.github.com/users/henriquem/followers","following_url":"https://api.github.com/users/henriquem/following{/other_user}","gists_url":"https://api.github.com/users/henriquem/gists{/gist_id}","starred_url":"https://api.github.com/users/henriquem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henriquem/subscriptions","organizations_url":"https://api.github.com/users/henriquem/orgs","repos_url":"https://api.github.com/users/henriquem/repos","events_url":"https://api.github.com/users/henriquem/events{/privacy}","received_events_url":"https://api.github.com/users/henriquem/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-14T19:52:11Z","updated_at":"2015-05-15T11:39:43Z","closed_at":null,"body":"Hi @saudet \r\nI have found an problem, if you fixed, please let me know Where I can get download again\r\n\r\nThe Problem is when I convert BufferedImage to IplImage its works fine:\r\n\r\n         public static IplImage convertBuffToIplImage(BufferedImage img){\r\n\t\t    Java2DFrameConverter converter1 = new Java2DFrameConverter();\r\n             OpenCVFrameConverter.ToIplImage converter2 = new OpenCVFrameConverter.ToIplImage();\r\n             IplImage iploriginal = converter2.convert(converter1.convert(img));\r\n\t\t     return iploriginal;\r\n\t     }\r\n\r\nThe BufferedImage from parameter has type 3 of Image.\r\nAfter 2 seconds, When I save the IplImage converted ocurred an error, in order to my application stop\r\n\r\nError StackTrace:\r\n\r\n    #Problematic frame:\r\n    # C  [opencv_highgui2411.dll+0xa020]  cvEncodeImage+0x15b0\r\n    #\r\n    # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows\r\n    # An error report file with more information is saved as:\r\n    # C:/worspace/test\\hs_err_pid9492.log\r\n\r\nOpenning the file hs_err_pid9492.log:\r\n\r\n    tack: [0x08070000,0x080c0000],  sp=0x080be228,  free space=312k\r\n    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)\r\n    C  [opencv_highgui2411.dll+0xa020]  cvEncodeImage+0x15b0\r\n    C  [opencv_highgui2411.dll+0x1e582]  cv::Mat::MStep::operator unsigned int+0x5ba2\r\n    C  [opencv_highgui2411.dll+0x647a]  cv::Mat::create+0x22da\r\n    C  [opencv_highgui2411.dll+0x8948]  cvSaveImage+0x128\r\n    C  [jniopencv_highgui.dll+0xad09]  Java_org_bytedeco_javacpp_opencv_1highgui_cvSaveImage__Ljava_lang_String_2Lorg_bytedeco_javacpp_helper_opencv_1core_00024CvArr_2+0x49\r\n    j  org.bytedeco.javacpp.opencv_highgui.cvSaveImage(Ljava/lang/String;Lorg/bytedeco/javacpp/opencv_core$IplImage;)V+33 "},"comment":{"url":"https://api.github.com/repos/bytedeco/javacv/issues/comments/102375362","html_url":"https://github.com/bytedeco/javacv/issues/150#issuecomment-102375362","issue_url":"https://api.github.com/repos/bytedeco/javacv/issues/150","id":102375362,"user":{"login":"maxsmirnov92","id":7045478,"avatar_url":"https://avatars.githubusercontent.com/u/7045478?v=3","gravatar_id":"","url":"https://api.github.com/users/maxsmirnov92","html_url":"https://github.com/maxsmirnov92","followers_url":"https://api.github.com/users/maxsmirnov92/followers","following_url":"https://api.github.com/users/maxsmirnov92/following{/other_user}","gists_url":"https://api.github.com/users/maxsmirnov92/gists{/gist_id}","starred_url":"https://api.github.com/users/maxsmirnov92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxsmirnov92/subscriptions","organizations_url":"https://api.github.com/users/maxsmirnov92/orgs","repos_url":"https://api.github.com/users/maxsmirnov92/repos","events_url":"https://api.github.com/users/maxsmirnov92/events{/privacy}","received_events_url":"https://api.github.com/users/maxsmirnov92/received_events","type":"User","site_admin":false},"created_at":"2015-05-15T11:39:43Z","updated_at":"2015-05-15T11:39:43Z","body":"Try to copy BufferedImage data to IplImage that way:\r\n\r\n\t\t\tBufferedImage bufImage = new BufferedImage(320, 240, BufferedImage.TYPE_3BYTE_BGR);\r\n\r\n                       // depth and channels number depend on source bufImage.getType() \r\n\t\t\tIplImage iplImage = IplImage.create(bufImage.getWidth(), bufImage.getHeight(),\r\n\t\t\t\t\topencv_core.IPL_DEPTH_8U, 3);\r\n\t\t\t\r\n\t\t\tiplImage.copyFrom(bufImage);\r\n\r\nbtw you can directly use BufferedImage or IplImage byte array:\r\n\r\n\t\t\tbyte[] data = new byte[iplImage.getByteBuffer().capacity()];\r\n\t\t\t\r\n\t\t\tiplImage.getByteBuffer().get(data);\r\n\t\t\t\r\n\t\t\tdata =  ((DataBufferByte) bufImage.getRaster().getDataBuffer()).getData();"}}