Posts

Showing posts from July, 2018

WiFi Direct on Android | IT IS TERRIBLE

Wifi Direct ; a  wireless communication channel that runs in parallel with your Wifi connection, guaranteeing point-to-point communication at speeds much faster than BLE. It sounds perfect for a local multiplayer game, or a camera peer network. It works up to 20 meters in open space and penetrates a single wall given your antenna is strong. Sounds perfect? I really wish it was. I spent over a month trying to ensure it works on as many devices as possible. In principle, it works exactly the same as BLE. You make your device visible for a wifi direct connection, and another device upon discovering it connects to the former. If you're planning to use Wifi Direct, I'd suggest you don't and figure out another mechanism. Here's a list of problems I faced: The SDK: The heart of the issue is each phone functions differently. The Android Software Development Kit ensures all devices above API 19 provide the same set of APIs, but the lower layers manufacturer implemen...

Java's Primitive Datatypes are Signed!

Image
It took me a whole 6 hours to write a color conversion from the YUV420P color space to the RGB color space. I thought I had a fairly good understanding of the various color formats (YUV420P, SP, 422, etc etc) and how to access individual Y, U, and V components; but I spent the better half of the 6 hours reading and re-reading the conversions and theory. The converted output's colors were completely messed up, and the images looked something like this: The colors are all messed up; but notice you don't see the 4 quadrant ghosts as you'd usually see in YUV conversions that go wrong. This hinted that my conversions/element access wasn't wrong.* Note, you needn't know what each of these really is or the formula of the conversion behind this. The crux of the problem was converting the given byte[] array input, to an int[] array output . I struggled because of a very simple yet hair-pulling gotcha; but it took me hours to realize where I was going wrong. All pr...