<p dir="auto">I'm trying to move a very simple OpenCV application to android. The code tries to access the camera from a qt for android . My qt code simply tries to access the camera using cv::VideoCapture like so:<br>
cv::VideoCapture cap(0); //  /dev/video0<br>
Camera cannot be opened,Permissions are open,chmod 777 /dev/video0,The camera still doesn't open.<br>
What did I add less? Or is my method wrong, Android can't open the camera in this way at all?<br>
Opencv version:　4.1.1<br>
qt version:　5.12.3<br>
android ndk: android-ndk-r19c</p>
<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 4.1.0</li>
<li>Operating System / Platform =&gt; Ubuntu 18.04 64 Bit</li>
<li>Compiler =&gt; Visual Studio Code</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">I am using the SSD face detector from the dnn module, and testing it on the Helen dataset <a href="http://www.ifp.illinois.edu/~vuongle2/helen/" rel="nofollow">http://www.ifp.illinois.edu/~vuongle2/helen/</a></p>
<p dir="auto">I have a strange behavior using the default settings, that is using the default 300x300 size:<br>
<code class="notranslate">cv::Mat inputBlob = cv::dnn::blobFromImage(image, 1.0, cv::Size(300,300), meanVal, mixchannels, false);</code></p>
<p dir="auto">It works ok on most of the files except on some where the bounding box is always shifted to the right<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/47775020/68882001-904b1e00-070e-11ea-9c86-d7c27015509f.jpg"><img src="https://user-images.githubusercontent.com/47775020/68882001-904b1e00-070e-11ea-9c86-d7c27015509f.jpg" alt="1242475639_1" style="max-width: 100%;"></a><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/47775020/68882026-9b9e4980-070e-11ea-904f-c358678b719c.jpg"><img src="https://user-images.githubusercontent.com/47775020/68882026-9b9e4980-070e-11ea-904f-c358678b719c.jpg" alt="2193639644_1" style="max-width: 100%;"></a></p>
<p dir="auto">51 images out of 2330 are concerned by this strange behavior. I cannot see any relationships between these (different sizes...) most of them are tightly cropped though.</p>
<p dir="auto">Now the strange thing is that if I use<br>
<code class="notranslate">cv::Mat inputBlob = cv::dnn::blobFromImage(image, 1.0, cv::Size(128,128), meanVal, mixchannels, false);</code></p>
<p dir="auto">Everything works perfectly, and the 51 images above are detected as expected.</p>
<p dir="auto">I tried to resize the image before, but It did not change anything.<br>
256x256 or 300x300 result in the same bug<br>
128x96 is ok<br>
I tried to use version 4.1.2, but I have a crash if I use the new prototxt and .caffemodel</p>
<h5 dir="auto">Steps to reproduce</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const std::string caffeConfigFile = &quot;deploy.prototxt&quot;;
const std::string caffeWeightFile = &quot;res10_300x300_ssd_iter_140000_fp16.caffemodel&quot;;
net = cv::dnn::readNetFromCaffe(caffeConfigFile, caffeWeightFile);
cv::Mat image = cv::imread(imageFile);
cv::Mat inputBlob = cv::dnn::blobFromImage(image, 1.0, cv::Size(300,300), cv::Scalar(104.0, 177.0, 123.0), false, false);
net.setInput(inputBlob, &quot;data&quot;);
cv::Mat detection = net.forward();
cv::Mat detectionMat(detection.size[2], detection.size[3], CV_32F, detection.ptr&lt;float&gt;());
int x1 = static_cast&lt;int&gt;(detectionMat.at&lt;float&gt;(0, 3) * image.cols);
int y1 = static_cast&lt;int&gt;(detectionMat.at&lt;float&gt;(0, 4) * image.rows);
int x2 = static_cast&lt;int&gt;(detectionMat.at&lt;float&gt;(0, 5) * image.cols);
int y2 = static_cast&lt;int&gt;(detectionMat.at&lt;float&gt;(0, 6) * image.rows);

cv::Rect faceBox = cv::Rect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
"><pre class="notranslate"><code class="notranslate">const std::string caffeConfigFile = "deploy.prototxt";
const std::string caffeWeightFile = "res10_300x300_ssd_iter_140000_fp16.caffemodel";
net = cv::dnn::readNetFromCaffe(caffeConfigFile, caffeWeightFile);
cv::Mat image = cv::imread(imageFile);
cv::Mat inputBlob = cv::dnn::blobFromImage(image, 1.0, cv::Size(300,300), cv::Scalar(104.0, 177.0, 123.0), false, false);
net.setInput(inputBlob, "data");
cv::Mat detection = net.forward();
cv::Mat detectionMat(detection.size[2], detection.size[3], CV_32F, detection.ptr&lt;float&gt;());
int x1 = static_cast&lt;int&gt;(detectionMat.at&lt;float&gt;(0, 3) * image.cols);
int y1 = static_cast&lt;int&gt;(detectionMat.at&lt;float&gt;(0, 4) * image.rows);
int x2 = static_cast&lt;int&gt;(detectionMat.at&lt;float&gt;(0, 5) * image.cols);
int y2 = static_cast&lt;int&gt;(detectionMat.at&lt;float&gt;(0, 6) * image.rows);

cv::Rect faceBox = cv::Rect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);

</code></pre></div>
<p dir="auto">This problem occurs on these 51 files from the Helen dataset:<br>
1021890651_1.jpg  164403300_1.jpg   2330954824_1.jpg  2584224650_1.jpg<br>
1037255513_1.jpg  1657180938_1.jpg  2346354291_1.jpg  2584536815_1.jpg<br>
103770709_1.jpg   167671232_1.jpg   2352345861_1.jpg  2607971564_1.jpg<br>
10407038_1.jpg    168907806_1.jpg   2365877276_1.jpg  266036271_1.jpg<br>
111714273_1.jpg   1908146310_1.jpg  240001815_1.jpg   2664748719_1.jpg<br>
1224500832_1.jpg  1961032923_1.jpg  2402251921_1.jpg  2705102720_1.jpg<br>
1242475639_1.jpg  1962410129_1.jpg  2407771006_1.jpg  2721024227_1.jpg<br>
131437823_1.jpg   2138681738_1.jpg  2419189561_1.jpg  2738187790_1.jpg<br>
1408008592_1.jpg  2193639644_1.jpg  2449764454_1.jpg  2837076619_1.jpg<br>
1418178512_1.jpg  2216370944_1.jpg  245801293_1.jpg   3006823882_1.jpg<br>
145548320_1.jpg   2223862191_1.jpg  245871800_1.jpg   30542618_1.jpg<br>
155271502_1.jpg   2264901367_1.jpg  2512750679_1.jpg  3247810519_1.jpg<br>
161868885_1.jpg   228950047_1.jpg   2546411220_1.jpg</p>