<p dir="auto">Transferred from <a href="http://code.opencv.org/issues/4497" rel="nofollow">http://code.opencv.org/issues/4497</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="|| Brian Kamery on 2015-07-22 14:14
|| Priority: Normal
|| Affected: branch 'master' (3.0-dev)
|| Category: java bindings
|| Tracker: Bug
|| Difficulty: 
|| PR: 
|| Platform: x64 / Windows"><pre class="notranslate"><code class="notranslate">|| Brian Kamery on 2015-07-22 14:14
|| Priority: Normal
|| Affected: branch 'master' (3.0-dev)
|| Category: java bindings
|| Tracker: Bug
|| Difficulty: 
|| PR: 
|| Platform: x64 / Windows
</code></pre></div>
<h2 dir="auto">Path format error failing on resource load.</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Hi, I hope this is not a duplicate - I tried to find a report of this, but there are many potential key words to search for.

When following several of the v3.0 java samples on windows (e.g. http://docs.opencv.org/3.0-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html), one gets errors such as:

OpenCV Error: Assertion failed (!empty()) in cv::CascadeClassifier::detectMultiScale, file C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\objdetect\src\cascadedetect.cpp, line 1634
Exception in thread &quot;main&quot; CvException [org.opencv.core.CvException: cv::Exception: C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\objdetect\src\cascadedetect.cpp:1634: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale
]
    at org.opencv.objdetect.CascadeClassifier.detectMultiScale_1(Native Method)
    at org.opencv.objdetect.CascadeClassifier.detectMultiScale(CascadeClassifier.java:103)
    at opencv.DetectFaceDemo.run(Hello.java:41)

The sample runs on linux without problem.

There are several &quot;answers&quot; on various boards that say to hardcode the absolute path ... this is obviously less than optimal, but did lead me to the &quot;right&quot; answer. I was able to debug this down to the format of the URL.getPath() response that are used for both the CascadeFilter and the Imgcodecs.imread() calls.

The URL.getPath() (and the URL.getFile()) calls both return an absolute path that starts with a '/' (e.g. &quot;/c:/opencv/...&quot;), but the imread() and the CascadeClassifier constructor are unableto handle this format on a windows file system. The in-code solution is url.getPath().substring(1), and the opencv utilities work great - but this too is less than optimal.

The ideal solution would be for opencv to handle the path starting with a '/' on windows as well. Even better, when the path that is passe din is unable to be handled opencv should fail in some way that is indicative of the real problem (e.g. the CascadeClassifier contructor and/or the imread() function throws a RuntimeException.)

I assume that the same issue would be true on the x86 windows platform as well as the x64."><pre class="notranslate"><code class="notranslate">Hi, I hope this is not a duplicate - I tried to find a report of this, but there are many potential key words to search for.

When following several of the v3.0 java samples on windows (e.g. http://docs.opencv.org/3.0-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html), one gets errors such as:

OpenCV Error: Assertion failed (!empty()) in cv::CascadeClassifier::detectMultiScale, file C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\objdetect\src\cascadedetect.cpp, line 1634
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\objdetect\src\cascadedetect.cpp:1634: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale
]
    at org.opencv.objdetect.CascadeClassifier.detectMultiScale_1(Native Method)
    at org.opencv.objdetect.CascadeClassifier.detectMultiScale(CascadeClassifier.java:103)
    at opencv.DetectFaceDemo.run(Hello.java:41)

The sample runs on linux without problem.

There are several "answers" on various boards that say to hardcode the absolute path ... this is obviously less than optimal, but did lead me to the "right" answer. I was able to debug this down to the format of the URL.getPath() response that are used for both the CascadeFilter and the Imgcodecs.imread() calls.

The URL.getPath() (and the URL.getFile()) calls both return an absolute path that starts with a '/' (e.g. "/c:/opencv/..."), but the imread() and the CascadeClassifier constructor are unableto handle this format on a windows file system. The in-code solution is url.getPath().substring(1), and the opencv utilities work great - but this too is less than optimal.

The ideal solution would be for opencv to handle the path starting with a '/' on windows as well. Even better, when the path that is passe din is unable to be handled opencv should fail in some way that is indicative of the real problem (e.g. the CascadeClassifier contructor and/or the imread() function throws a RuntimeException.)

I assume that the same issue would be true on the x86 windows platform as well as the x64.
</code></pre></div>
<h2 dir="auto">History</h2>
<p dir="auto">Reason:</p>
<ul dir="auto">
<li>duplicates behavior and implementation (fixed type, fixed size)</li>
</ul>
<p dir="auto"><a href="https://github.com/opencv/opencv/blame/0105f8fa38ec867a8e4bbc74c402afcd0e296194/modules/core/include/opencv2/core/mat.hpp#L181">relates</a> <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="220088195" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/8535" data-hovercard-type="pull_request" data-hovercard-url="/opencv/opencv/pull/8535/hovercard" href="https://github.com/opencv/opencv/pull/8535">#8535</a></p>