Why QCamera::CaptureVideo isn't supported? - c++

I'm trying to create an application which uses camera API, based on an example from Qt.
Problem:
Following call to check if video capture is supported returns false.
camera->isCaptureModeSupported(QCamera::CaptureVideo) //returns false.
If I try to ignore it and start recording - recording does not start and I get no error messages ( Also, QMediaRecorder::errorString() and QCamera::errorString() return empty strings ).
Image from camera correctly showed in QCameraViewFinder.

It basically is a known bug in windows.
https://bugreports.qt.io/browse/QTBUG-30541
https://doc-snapshots.qt.io/qt5-5.5/qtmultimedia-windows.html
It should work in other platforms, though.

Related

OpenCV destroyWindow() not working with multiple windows

I am using openCV library to open and display multiple images. I am doing this with multiple windows created in order to display each image. In order to achieve display of multiple windows at the same time, I am using waitKey() only after the last image.
cv::namedWindow("Window1");
cv::imshow("Window1", myImage1);
cv::namedWindow("Window2");
cv::imshow("Window2", myImage2);
cv::waitKey(1000);
As can be seen from the code, my goal is to give the user 1s of time to press any key, otherwise I want to destroy one of the windows (for the purpose of this question it can be either one). I want to achieve this by using openCV's function destroyWindow().
Below my entire code can be seen:
cv::namedWindow("Window1");
cv::imshow("Window1", myImage1);
cv::namedWindow("Window2");
cv::imshow("Window2", myImage2);
cv::waitKey(1000);
cv::destroyWindow("Window2");
The goal of this code snippet should be that only "Window1" remains displayed, if 1s goes by, with the user not pressing any key.
However, this does not happen. The end result is that none of the windows are destroyed.
I have tested the following code snippet, which results in both windows being closed:
cv::namedWindow("Window1");
cv::imshow("Window1", myImage1);
cv::namedWindow("Window2");
cv::imshow("Window2", myImage2);
cv::waitKey(1000);
cv::destroyWindow("Window1");
cv::destroyWindow("Window2");
The same results when I use destroyAllWindows() function (which makes sense).
My question now is, why can't I destroy only one of the windows?
Additional info:
Using Ubuntu 20.04.
OpenCV version is 4.2.
Working in C++
Changing the order of which window I want to destroy changes nothing.
Tried to replicate it, facing this issue in Python as well on Ubuntu. If you are still stuck, you can try a stopgap solution of reshowing only the one you wanted to show provided the user has pressed a key or not by storing the result of waitKey in some variable. If it is -1 then no key has been pressed.
I have provided a sample solution in Python which you shouldn't face any difficulties converting to C++.
import cv2
img1 = cv2.imread('img1.png')
img2 = cv2.imread('img2.png')
cv2.namedWindow('img1')
cv2.imshow('img1', img1)
cv2.namedWindow('img2')
cv2.imshow('img2', img2)
key = cv2.waitKey(5000)
if key == -1:
cv2.destroyAllWindows()
cv2.imshow('img1', img1)
cv2.waitKey(0)
else:
# do whatever destroy both or keep on showing both using cv2.waitKey(0)
cv2.destroyAllWindows()
I have reached a solution by adding startWindowThread() before adding each of the windows.
An important thing to note is also that I have built openCV using GTK option, so my solution is tested only on GTK not on others.
startWindowThread() is used only with GTK as noted here: https://github.com/opencv/opencv/issues/7562 - for others the function is empty.

cv::text::OCRTesseract not respecting filters on Raspberry Pi

I am using the OCRTesseract extra module in openCV for text recognition on a raspberry pi model 3. I want it to only detect single, uppercase characters. The following initilization code works perfectly fine on my desktop and laptop:
Ptr<OCRTesseract> tess;
tess = OCRTesseract::create(NULL, NULL, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 3, 10);
however when run on the run on the raspberry pi it seems to ignore the filters and will often give lowercase characters and symbols. Occasionally giving multiple characters at the same time.I have tried:
tess->setWhiteList("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
to no avail.
Any suggestions? The OCR works fine apart from this issue. Allowing it to detect lowercase letters/symbols is resulting in a lot more false positives than I am happy with.
I do not have the rep needed to comment. My guess would be a faulty installation of tesseract or opencv in your pi considering the fact that it ignores the whitelist and give multiple character when psm is set to 10 (single character).
Can you provide the version of your tesseract and opencv?
If possible, try to save the image as a file then use tesseract from command line to see whether it works properly.
After doing some research I found it to be a bug in tesseract version 4.00.00alpha (which just so happened to be the version I was running on the PI).
Setting the OEM mode to 0 completely fixed the issue. The following initilization code works as intended:
Ptr<OCRTesseract> tess;
tess = OCRTesseract::create(NULL, NULL, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 10);

I have two webcams, but QCameraInfo::availableCameras returns empty array

According to the documentation, QCameraInfo::availableCameras should return list of available cameras. There's no catch to it according to the docs.
But still, I have two webcams and the array of available cameras is returned empty. What can I do? Is this even in the scope of programming, or does this mean Qt only supports limited subset of webcams?
The OS I'm using right now is Windows 7x64.
I have this Problem too.Then I read about the example.
I found that once you have declared QCamera object.it will return the right info.
Like this :`
QCamera *cam = new QCamera;
qDebug()<<QCameraInfo::availableCameras().count();`
I have one camera,so it returns 1 at last;
Try to copy the mediaservice plugin folder into your application dir (where the exe resides).
At least that solved this specific problem for me.
You need to resolve your dependencies (like Thomas D. mentioned).
(take a look at http://doc.qt.io/qt-5/windows-deployment.html )
From yourpathof\Qt\...subdir...\bin
execute
windeployqt.exe --debug YOURPATH\Debug
or
windeployqt.exe YOURPATH\Debug

SDL_RenderCopy() has strange behavior on Raspberry PI

This is driving me up the wall..
I've got a very simple SDL2 program.
It has a array of 3 SDL_Texture pointers.
These textures are filled as follows:
SDL_Texture *myarray[15];
SDL_Surface *surface;
for(int i=0;i<3;i++)
{
char filename[] = "X.bmp";
filename[0] = i + '0';
surface = SDL_LoadBMP(filename);
myarray[i] = SDL_CreateTextureFromSurface(myrenderer,surface);
SDL_FreeSurface(surface);
}
This works, no errors.
In the main loop (which is just a standard event loop waiting for SDL_QUIT, keystrokes and a user-event which a SDL_Timer puts in the event queue every second) I just do (for the timer triggered event):
idx = (idx+1) % 3; // idx is global var initially 0.
SDL_RenderClear(myrenderer);
SDL_RenderCopy(myrenderer, myarray[idx], NULL, NULL);
SDL_RendererPresent(myrenderer);
This works fine for 0.bmp and 1.bmp, but the 3rd image (2.bmp) simply shows as a black field.
This is structural.
If I alternate the first 2 images they are both fine.
If I alternate the 2nd and 3rd image the 3rd image doesn't show.
If I use more than 3 images then 3 and upwards show as black.
Loading order doesn't matter. It starts going wrong with the 3rd image loaded from disk.
All images are properly formatted BMP's.
I even saved 2.bmp back to disk under a different name by using SDL_SaveBMP() after it was loaded to make sure it got loaded in memory OK. The new file is bit for bit identical to the original.
This program, without modifications and the same bmp files, works fine on OSX (XCode5) and Windows (VC++ 2012 Express).
The problem only shows on the Raspberry PI.
I have placed explicit error checks on every call that can leave a result/error-code (not shown in the samples above for brevity) but all of them show "no error".
I have used the latest stable source set of www.libsdl.org and compiled as instructed (configure, make, make install, etc.).
Anybody got any idea what could be going on ?
P.S.
Keyboard input doesn't seem to work either on my PI, but I haven't delved into that yet.
Answering myself as I finally figured it out myself...
I finally went back to the README-raspberrypi.txt that came with the SDL2 sources.
I didn't read it carefully enough the first time around...
Problem 1: I'am running on a FULL-HD display. The PI's default GPU memory is 64MB which is not enough for large displays and double-buffering. As suggested in the README I increased this to 128MB and this solved the black image problem.
Problem 2: Text input wasn't working because my user-account was not in the input group. I had added the default "pi" account to the input group initially, but when I later started using another account I forgot to add that user to the group.
In short: Caught by my own (too) quick skimming of the documentation.

Displaying CAknInformationNote on device

I am fetching the call-logs, appending them on information note using:
CAknInformationNote* note = new (ELeave) CAknInformationNote;
note->ExecuteLD(callLogs);
I perfectly run on emulator (show all call-logs on note) but nothing shows up when run on the actual device (a Nokia N73). Any ideas?
i think you should use some kind of file logging(you can even use RFile) and see till what point your application executing.i am assuming you dont see a crash/panic on hardware.i doubt if you are able to get the call logs properly first on device.