{"id":1839,"date":"2022-08-30T15:19:52","date_gmt":"2022-08-30T15:19:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/02\/opencv-convert-char-to-cvmat-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:19:52","modified_gmt":"2022-08-30T15:19:52","slug":"opencv-convert-char-to-cvmat-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/opencv-convert-char-to-cvmat-collection-of-common-programming-errors\/","title":{"rendered":"OpenCV: Convert char* to cv::Mat-Collection of common programming errors"},"content":{"rendered":"<p>I want to develop a server-client face recognition application. My problem is when I try to convert the picture received as a char* to cv::Mat, I get the following error: &#8220;Unhandled exception at 0x61ed3ea0 (opencv_highgui249d.dll) in &#8230;exe: 0xC0000005:Access violation reading location 0x00431000.&#8221;<\/p>\n<p>This is my code for cliend application (send Mat image as a String):<\/p>\n<pre><code>matCameraBitmap = new Mat();\n\/\/... \nBufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));\nout.write(matCameraBitmap.toString());\nout.flush();\n<\/code><\/pre>\n<p>and the code server application (receive image as char*):<\/p>\n<pre><code>char buffer[1024];\n\nmemset(buffer, 0, buffer_len);\nif((bytecount = recv(new_sock, buffer, buffer_len, 0)) == SOCKET_ERROR)\n{\n        fprintf(stderr, \"Error receiving data %d\\n\", WSAGetLastError());\n        goto END;\n}\n\nTempMat = cv::Mat(100, 100, CV_8UC1, buffer);   \/\/all images are 100x100\nimshow(\"this is a test\", TempMat);\n<\/code><\/pre>\n<p>Do you have any idea how to solve this error?<\/p>\n<p id=\"rop\"><small>Originally posted 2013-12-02 20:57:17. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I want to develop a server-client face recognition application. My problem is when I try to convert the picture received as a char* to cv::Mat, I get the following error: &#8220;Unhandled exception at 0x61ed3ea0 (opencv_highgui249d.dll) in &#8230;exe: 0xC0000005:Access violation reading location 0x00431000.&#8221; This is my code for cliend application (send Mat image as a String): [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1839","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1839"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1839\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}