Select Timeout error in Ubuntu - Opencv - c++

I am trying to set OpenCv up for my final year project and have run into a couple of problems. I successfully got it set up in Ubuntu following this tutorial.
The problem I am having now is keeping this sample program running. The program is face detection using a webcam.
It runs fine for 3 or 4 seconds and then the capture gets stuck with a single frame in the window. The console displays the following output.
tom#ubuntu:~/College/opencv/faceDetect_sample$ make
./faceDetect --cascade="haarcascade_frontalface_alt.xml" --nested-cascade="haarcascade_eye_tree_eyeglasses.xml"
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
init done
opengl support available
select timeout
select timeout
select timeout
select timeout
select timeout
select timeout
^Cmake: *** [run] Interrupt
If anybody has an idea of where to go from here, I would really appreciate some help !

Try this:
modprobe uvcvideo nodrop=1 timeout=6000
and if that works, simply make the changes permanent by editing /etc/modprobe.d/modprobe.conf
Try increasing the timeout to a ridiculously large number. That should fix the issue, or at least it worked for me. It's just that the call to select returns no ready descriptors, and that may be caused by the video driver, or device one.
If that does not work,
Enable module traces:
sudo echo 0xffff > /sys/module/uvcvideo/parameters/trace
Run the program until the error is found, and stop it as soon as possible. Then disable the traces:
sudo echo 0 > /sys/module/uvcvideo/parameters/trace
Search with dmesg for error messages.

It can be resolved if we add the following lines to the code:
VideoCapture capture(<device id>);
capture.set(CV_CAP_PROP_FRAME_WIDTH , 352);
capture.set(CV_CAP_PROP_FRAME_HEIGHT , 288);
Following is a good link where the solution is explained in detail:
http://derekmolloy.ie/beaglebone/beaglebone-video-capture-and-image-processing-on-embedded-linux-using-opencv/

I had the same issue with my Logitech C920. I tried the following solutions without any success. However, it worked like a charm with the C930e webcam so I guess the V4L API has something to do with it.

Related

Dronekit-Python Error with Raspberrypi4-Ubuntu20.04 "dronekit.APIException"

I'm trying to run the script by python2-3 (alias).
This is for drone's flight so I'm using dronekit.
But I got this error as below.
Please help me to solve this error.
Ubuntu20.04
Raspberrypi 4 Board
Dronekit 2.9.2
Python2.7 & Python3.8
enter image description here
In the terminal output that you posted, there is a Timeout exception at the line which reads vehicle = connect('/dev/ttyAMA0', baud=921600, wait_ready=True) . More details about your setup would be useful, but I'm going to assume you are using a serial radio to communicate with your drone. If that's true, some troubleshooting steps may be:
Make sure the radio is being mounted to /dev/ttyAMA0.
Make sure the baud rate for the radio is 921600. If it's something different, pass this value in as the baud parameter in connect.
When asking questions, it's best to give as much detail as possible, and, as the above commenter said, please include code as text instead of linking to screenshots.

How can i start the GDB server in stm32cubeide?

right now I am trying to program on the STM32G0-Disco-board with the program stm32cubeide on WIN10.
This worked fine until it didn't.
My problem right now is that I can't debug/run it anymore. This is the first day I used this program, which doesn't mean it didn't worked at the beginning. Building, Debugging and Running worked just fine.
But now I get this error message:
Error in final launch sequence:
Failed to start GDB server
Failed to start GDB server
Error in initializing ST-LINK device.
Reason: (4) No device found on target.
I already tried multiple usb-ports, the jumper on the board. I even looked in this Batchfile:
C:\ST\STM32CubeIDE_1.3.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.win32_1.3.0.202002181050\tools\bin
ST_LINK_gdbserver because it was mentioned in other threads and i just got this:
ERROR: Couldn't locate STM32CubeProgrammer in '..\STM32CubeProgrammer\bin\', use -cp
GDB server exited.
And oh yeah i already looked into the device manager and everything looks good to me.
Help is much appreciated!
I had the same problem and i managed to solve it . It turns out that my antivirus software (avast) was preventing the debugger from starting by removing the file ST_LINK_gdb.exe from its place and putting it in the antivirus chest.
The solution was to open the virus chest and and restore the file and also add an exception. And this solved the problem.
Short BOOT0 (see the pinout of your board) to the 3.3 V, then power cycle, and program it
I had the same problem, thank you Chris for your suggestions!
To be clear, these are the steps I followed:
short BOOT0 to +3.3V (BOOT0 and 1 are pulled low via 1K on my board)
cycle power with the short in place
remove the short
cycle power again
good to go!

QT Terminal Example not sending data

Qt "Terminal Example" is not working as expected with RS232.
I am using this as a boilerplate for my serial GUI application but cannot get it to send data to my device. Using the same settings in PUTTY I get a perfect output. I have narrowed it down to the issue that it will only send a single message and then no more. Is there some loop in there? I've already put debug statements all over to check unknown actions with no luck.
I checked what functions are outputting but I cannot see anywhere that it closes the port.
I also thought that maybe it was just me not sending the \r command but even this did nothing. I simply send the first message and then it does nothing.
I have tried sending it manually, with commands like these:
m_serial->write("command");
m_serial->write("command\r");
I have also tried following a solution here: How to make QSerialPort from Qt5.13.1 work?
I tried to update to the newest version and the maintenance tool did not find repository so I just did a clean install with 5.12.5 and same problem persists.
In my image, the first set of open-close is the terminal example. The second set is Putty working. I am definitely connecting because the error checking and serial port info I get from Qt is correct.
EDIT
My port settings are:
Baud: 9600
Data bits: 8
Stop Bits: 1
Parity: None
Flow Control: None
Qt Version: 5.13.1, 5.12.5

Vulkan on X11: vkGetPhysicalDeviceSurfaceCapabilitiesKHR error

I am trying to get Vulkan running under X11.
I have (apparently) successfully created an instance, device and surface, and several calls relating to the surface also succeed, and even return reasonable values (for example vkGetPhysicalDeviceSurfaceFormatsKHR returns two formats). However, when I call vkGetPhysicalDeviceSurfaceCapabilitiesKHR, I get the following:
X Error of failed request: BadDrawable (invalid Pixmap or Window parameter)
Major opcode of failed request: 14 (X_GetGeometry)
Resource id in failed request: 0x5800009
Serial number of failed request: 42
Current serial number in output stream: 42
The X11 Window is 0x5800009, as referenced in the error. I am using Vulkan SDK 1.0.5, and Nvidia 364.12 drivers (if that is relevant).
On the hunch that Vulkan was querying something about the Window that had not yet been created, I put a XSync(<display>, false) call before this one, and that seems to have solved the issue.
I am not sure whether this is required for proper operation (I am not an X11 expert), or whether this is an issue with Vulkan itself. If somebody has a better explanation, I would love to hear it.
I had the same error on Linux with XCB and I resolved it (with the help of MuertoExcobito's answer) by calling xcb_flush after the window creation.
I came across that same error when I bound ::XDisplay to VkSwapchainCreateInfoKHR.dpy before a window handle was actually created. So long as I keep that structure updated during resize events (with both .dpy and .window), everything continues to work fine.

How to take screenshots on Raspberry Pi effectively?

I'm trying to take a screenshot of the screen in my C++ code. The code is executed in the terminal.
I only have few milliseconds to capture the screen so I would like to use a code that is possibly really fast.
So far I have tried:
System("import -window root screenshot.jpg");
but It fails stating that it doesn't recognize import.
I have also tried:
System("sudo scrot");
which fails as well with this error: "Can't open X display. It is running, yeah?"
Any ideas on how to take a screenshot of screen really fast?