Month: June 2017

Using an Android phone as WebCAM over USB

I was looking for a way to use my smartphone as webcam and found this page:

http://www.skipser.com/p/2/p/android-as-webcam.html

I tried the second option listed in the post, an application called DroidCAM. The post is a little bit outdated and currently the DroidCAM has a client for Linux.

You need to compile a kernel module that will “fake” a device driver webcam, the instructions to compile and test it is here:

http://www.dev47apps.com/droidcam/linuxx/

A limitation is the max resolution of 640×480.

Testing LLVM LIBC++ on NuttX

Clone NuttX:

$ git clone https://bitbucket.org/nuttx/nuttx

Clone NuttX’s Apps:

$ git clone https://bitbucket.org/nuttx/apps

Clone libc++ for NuttX:

$ git clone https://bitbucket.org/acassis/libcxx

Install the libc++ on NuttX:

cd libcxx
$ ./install.sh ../nuttx/
Installing LLVM/libcxx in the NuttX source tree
Installation suceeded

Modify the HelloXX example to use sstream:

$ cd ..
$ cd apps

Download 0001-Modify-helloxx-to-test-sstream.patch: https://gist.github.com/acassis/504e86d992a2fc459784c6284aa90e53

Apply it:

$ git am 0001-Modify-helloxx-to-test-sstream.patch

Add (l)gamma to NuttX and add helloxx example:

$ cd ..
$ cd nuttx

Download 0001-Add-gamma-and-lgamma.patch: https://gist.github.com/acassis/4fc95d3ecba3c4829eac303d5704dc76

Apply it:

$ git am 0001-Add-gamma-and-lgamma.patch

Download 0001-Add-helloxx-C-example-to-STM32F4Discovery.patch: https://gist.github.com/acassis/b17e90835eeffb58a35651a4e0d0503d

Apply it:

$ git am 0001-Add-helloxx-C-example-to-STM32F4Discovery.patch

Configure NuttX to use the helloxx example:

$ cd tools
$ ./configure.sh stm32f4discovery/helloxx

Compile it:

$ cd ..
$ make

Flash it:

$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x08000000"

Restart NuttX, you should see:

Hello World! 42                                                              
helloxx_main: Saying hello from the dynamically constructed instance         
CHelloWorld::HelloWorld: Hello, World!!                                      
Hello World! 42                                                              
helloxx_main: Saying hello from the instance constructed on the stack        
CHelloWorld::HelloWorld: Hello, World!! 
helloxx_main: Saying hello from the statically constructed instance
CHelloWorld::HelloWorld: Hello, World!! 

Testing cWebSocket

These are the steps I did to compile the cWebSocket (https://github.com/m8rge/cwebsocket) :

alan@machine:~/cwebsocket/lib$ gcc -c websocket.c -o websocket.o
alan@machine:~/cwebsocket/lib$ ar rcs libwebsocket.a websocket.o 
alan@machine:~/cwebsocket/lib$ ls -l
total 60
-rw-rw-r-- 1 alan alan  2307 Jun  3 13:15 aw-base64.h
-rw-rw-r-- 1 alan alan  3589 Jun  3 13:15 aw-sha1.h
-rw-rw-r-- 1 alan alan 14108 Jun  3 17:19 libwebsocket.a
-rw-rw-r-- 1 alan alan 11144 Jun  3 13:15 websocket.c
-rw-rw-r-- 1 alan alan  4902 Jun  3 13:15 websocket.h
-rw-rw-r-- 1 alan alan 13856 Jun  3 17:19 websocket.o

alan@machine:~/cwebsocket/lib$ cd ../x86_server/
alan@machine:~/cwebsocket/x86_server$ gcc -I../lib/ -L../lib/ main.c -o websocket -lwebsocket

This is the debug when opening the client.html example:

$ ./websocket 
opened 0.0.0.0:8088
connected 127.0.0.1:36808
in packet:
GET /echo HTTP/1.1
Host: localhost:8088
User-Agent: Mozilla...
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Sec-WebSocket-Version: 13
Origin: null
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Key: 4MHamm...==
Connection: keep-alive, Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket


out packet:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: Gg+sXSeGc...=


in packet:
��c^�M;�9
0�
out packet:
�testing

Studying English: Tips to improve your pronounce

English is the lingua franca of the Internet and of the global business, then you need to speak it.

You can improve your pronounce using these tips:

1) Start with VOA (Voice Of America) Special English: https://learningenglish.voanews.com/

In this site you will find many audios of news where the speakers will read it slowly. Also you can get the scripts to follow the news.

2) Listen and sing to the musics and its lyrics. Listening and singing is a nice way to your brain understand how the words are linked together and how to speak it more naturally. In the real life “an architect” is pronounced more like “anarchitect”.

3) Use the site Youglish (http://youglish.com) to help you to discover videos with some words that you are looking for.

4) Improve your pronounce with ex-President Barack Obama. Yes that is right, Barack Obama is a good reference as an English speaker and you can find thousands of his weekly speaks at https://obamawhitehouse.archives.gov/briefing-room/weekly-address . Then you should record your audio speaking the script at same time as you listen the Barack Obama audio. Then use Audacity to compare the audios and to discover each words we need to improve.

Note: some Weekly Address only have the video, you can download the video from youtube using the programa youtube-dl and you can extract the audio using FFMpeg, i.e: $ ffmpeg -i 20170107\ Weekly\ Address\ HD-7G5kMmnAp_8.mp4 -q:a 0 -map a 20170107_Weekly_Address.mp3