BBB: GPIO signal won't stay high - beagleboneblack

So I have a BeagleBone Black board, and I want to be able to set some GPIO pin from a low value to a high value.
For achieving this I'm using the BlackLib1 library (a C++ library that offers general access to all beaglebone's pins).
That library haves a class called BlackGPIO that offers the functionality that I want.
BlackLib::BlackGPIO NSLP_pin(BlackLib::GPIO_61, BlackLib::output, BlackLib::SecureMode);
auto NSLP_pinMode = NSLP_pin.getValue();
NSLP_pin.setValue(BlackLib::low);
I expect that this lines of code will set the signal from a low value to a high one (the signal is low by default).
The problem is that the signal goes high only for about ~10ms (measured on a scope), and after that it goes low again.
What I do wrong?
How can I set the some GPIO pin at a certain value, and remain like that until I change it?
[1] link

The link specifies to export the BBB pins from command line and to set it HIGH or LOW. You can develop a small C++ function to send those commands to kernel to export, ON/OFF the BBB pins. I'm using the same method in my C application and it works perfect.
Example code snippet in C to Enable the pin:
FILE *GPIO;
GPIO = fopen("/sys/class/gpio/gpio65/direction", "w");
fseek(GPIO,0,SEEK_SET);
fprintf(GPIO,"61");
fflush(GPIO);
fclose(GPIO);

Related

How to distinguish between different license plates using OpenCV

Currently working on licentiate detection system and need some guidance on how to proceed.
I can capture (via video playback) and with the help of an open source library called OpenALPR display the license plates directly to the terminal, now the issue is it capture on a frame by frame basis so it capture the same license plate multiple times. I added a frame skip variable and now it skips however many number of frames I want it to but the issue is still there.
Furthermore, I'd like to distinguish between different license plates if possible but don't know how to work around that, I've attempted employing basic object detection and detection but failed miserably.
Below is an image of the program running, as seen it detects a single license plate and display multiple instance of it, now the issue is I expect it to move on to the next car and display Plate#1, unfortunately it does not and continues feeding into Plate #0
Program Running
Program Running
The function that actually helps display the license plate text is below, really the first line does all the work. OpenALPR is a pretty powerful.
results = alpr.recognize_ndarray(frame)
for i, plate in enumerate(results['results']):
best_candidate = plate['candidates'][0]
print('Plate #{}: {:} ({:}%)'.format(i,
best_candidate['plate'].upper(),
best_candidate['confidence']))
I'd like some guidance towards how I can solve this problem? Which is basically distinguish between different license plates.
It is a general problem without general solution, because it highly depends on context. Some thoughts:
If it is a video feed you can track the plate movement, the track will "jump" when it detects another plate. Let say the maximum optical flow velocity is 100 px/frame, if it jumps more than this threshold, you can suppose it is a new plate.
Depending on you video quality and detector, may there be spurious jumps, I would add a Kalman filter or any simple filter.
Perhaps there is a minimum time lapse between a plate goes out the image and the next arrives. You can use a time threshold to trigger the "changed plate alert" event.

Is it possible to use beaglebone (black) analog pins as GPIOs?

Analog pins of arduino boards can be used as GPIO but is it also possible for the beaglebone boards ? Especially the black model.
And if it is possible, how to do it ?
Please refer to e.g. the BBB SRM (System Reference Manual), specifically: 7.1.2 Connector P9 or "Table 13. Expansion Header P9 Pinout" in the PDF version.
tl;dr: no
Please also note that those pins only tolerate up to 1.8V. Applying any higher voltage will destroy the ADC and possibly affect the whole chip.

Why is NodeMCU triggering gpio in reverse when using Lua?

When using Lua and the GPIO module with my NodeMCU, my the high and low values are occurring in reverse.
I downloaded my build from NodeMCU custom builds: Link
To turn on the blue LED on the ESP8266, normally you set GPIO pin 0 to high. What's happening for me is I have to set it to low.
This is what I'm executing in the serial console to light up the blue LED:
gpio.write(0, gpio.LOW)
If I take this pin and directly connect it to ground, it also lights up the blue LED which I believe is correct.
What's causing my low and high values to be read incorrectly in NodeMCU?
This is normal - the on-board LED turns on with a LOW value and turns off with a HIGH value.
I've programmed these both in Lua and Arduino and the on-board LED works the same way.
Try attaching a regular LED to the same pin. You'll notice that it's inverse -- it will turn on with a HIGH value and off with a LOW value.
HIGH means the pin is set to supply voltage (it is "sourcing" voltage) and LOW means it is set to 0V (it is "sinking" voltage).
Assuming this board is wired like most of them, this is the rough schematic of the LED (note that "0" in gpio.write refers to GPIO16 hardware pin per the diagram here):
Diagram of the GPIO16 pin
You can see the diode is "pointing" in the direction that current should flow through it for the diode to light, which is "towards" GPIO16. So to get current to flow you need to set GPIO16 to LOW (0V) so there is a voltage difference. Otherwise both sides of the diode are at 3.3V and no current flows.

openCV: is it possible to time cvQueryFrame to synchronize with a projector?

When I capture camera images of projected patterns using openCV via 'cvQueryFrame', I often end up with an unintended artifact: the projector's scan line. That is, since I'm unable to precisely time when 'cvQueryFrame' captures an image, the image taken does not respect the constant 30Hz refresh of the projector. The result is that typical horizontal band familiar to those who have turned a video camera onto a TV screen.
Short of resorting to hardware sync, has anyone had some success with approximate (e.g., 'good enough') informal projector-camera sync in openCV?
Below are two solutions I'm considering, but was hoping this is a common enough problem that an elegant solution might exist. My less-than-elegant thoughts are:
Add a slider control in the cvWindow displaying the video for the user to control a timing offset from 0 to 1/30th second, then set up a queue timer at this interval. Whenever a frame is needed, rather than calling 'cvQueryFrame' directly, I would request a callback to execute 'cvQueryFrame' at the next firing of the timer. In this way, theoretically the user would be able to use the slider to reduce the scan line artifact, provided that the timer resolution is sufficient.
After receiving a frame via 'cvQueryFrame', examine the frame for the tell-tale horizontal band by looking for a delta in HSV values for a vertical column of pixels. Naturally this would only work when the subject being photographed contains a fiducial strip of uniform color under smoothly varying lighting.
I've used several cameras with OpenCV, most recently a Canon SLR (7D).
I don't think that your proposed solution will work. cvQueryFrame basically copies the next available frame from the camera driver's buffer (or advances a pointer in a memory mapped region, or blah according to your driver implementation).
In any case, the timing of the cvQueryFrame call has no effect on when the image was captured.
So as you suggested, hardware sync is really the only route, unless you have a special camera, like a point grey camera, which gives you explicit software control of the frame integration start trigger.
I know this has nothing to do with synchronizing but, have you tried extending the exposure time? Or doing so by intentionally "blending" two or more images into one?

How to disable automatic white balance from Webcam?

I got a webcam and I'm running some algorithm on the received images to find movements in it.
But, the automatic auto white balance is changing the excepted result of the pixels color variance.
That's why I'm trying to disable it.
Some one knows a way to get the web can image with out this automatic color balance or disable it ?
Tks
If you are on Linux, you can test disabling automatic white balance using the uvcdynctrl command line utility. This is not a permanent solution, since these settings are reset every time the webcam is disconnected from the computer. As of OpenCV 2.1, configuring white balance is not supported using cv::VideoCapture::set(). Assuming this is still the case in OpenCV 2.2, you will need to use another library to configure your webcam and capture frames.
If you on Linux, you can see an example of using direct Video4Linux (V4L) syscalls to do this in one of my Github projects.
In my case I found on driver two options that must be disabled, auto white exposure and auto white balance, I disable both of them and the image got as I needed.

Resources