Friday, 23 March 2018

OpenCV Helloworld Trouble


Just want to quickly do an openCV helloworld:

#include <iostream>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

int main()
{
Mat srcImage = imread("lena.jpg");
imshow("image",srcImage);

waitKey(0);

return 0;
}

Compile:
g++ `pkg-config opencv --cflags` opencv.cpp -o opencv `pkg-config opencv --libs` 

but I got this error:
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /home/boris/Softwares/openCV/opencv/modules/highgui/src/window.cpp, line 611 terminate called after throwing an instance of 'cv::Exception' what(): /home/boris/Softwares/openCV/opencv/modules/highgui/src/window.cpp:611: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage

Something is wrong with QT?

sudo apt-get install libqt4-dev
cmake -D WITH_QT=ON ..
make
sudo make install

ref:
https://stackoverflow.com/questions/14655969/opencv-error-the-function-is-not-implemented
https://blog.csdn.net/keith_bb/article/details/52864851




Thursday, 22 March 2018

Just Installed openCV


Error:
./opencv: error while loading shared libraries: libopencv_highgui.so.3.3: cannot open shared object file: No such file or directory

$ sudo ldconfig


ref:
https://github.com/pjreddie/darknet/issues/382

Install openCV on Ubuntu 16.04

I was installing openCV following the instruction from the first google search:
          https://www.learnopencv.com/install-opencv3-on-ubuntu/

But I met the following problems so far.

sudo apt-get install git gfortran

error:
The following packages have unmet dependencies:
 gfortran : Depends: gfortran-5 (>= 5.3.1-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

solution:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gfortran-5
Now do it again and it works.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

sudo apt-get install libjpeg8-dev libjasper-dev libpng12-dev

error:
The following packages have unmet dependencies:
 libjasper-dev : Depends: libjasper1 (= 1.900.1-debian1-2.4ubuntu1) but 1.900.1-debian1-2.4ubuntu1.1 is to be installed
E: Unable to correct problems, you have held broken packages.

solution:
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev

Now do it again and it works.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

~$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) 
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

Solution:
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
~$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

~$ sudo dpkg --configure -a

Do it again and worked:
~$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

~$ sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

error:
The following packages have unmet dependencies:
 libgstreamer-plugins-base0.10-dev : Depends: libglib2.0-dev but it is not going to be installed
 libgstreamer0.10-dev : Depends: libglib2.0-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Solution:
Install the dependency libglib2.0-dev:
sudo apt-get install libglib2.0-dev libglib2.0-0=2.48.0-1ubuntu4

Do it again and worked:
~$ sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

sudo apt-get install qt5-default libgtk2.0-dev libtbb-dev
I jumped over qt5-default, too many dependencies...so just:
~$ sudo apt-get install libgtk2.0-dev libtbb-dev

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

sudo apt-get install python-dev python-pip python3-dev python3-pip

errors:
The following packages have unmet dependencies:
 python3-pip : Depends: python-pip-whl (= 8.1.1-2) but 8.1.1-2ubuntu0.4 is to be installed
               Recommends: python3-setuptools but it is not going to be installed
               Recommends: python3-wheel but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

solution:
Don't know yet...I jumped over python3-pip for now.

/////////////////////////////////////////////////////////////////////////////////////////////////////

OK finally cmake...but I got errors. After trying a lot to install some dependencies like qt5, I still couldn't get rid of the errors. I found the official website has a tutorial about installation:
            
                https://docs.opencv.org/trunk/d2/de6/tutorial_py_setup_in_ubuntu.html

Note that you have to delete ./build directory and create a new folder and do:
$ cmake ../

...and it worked!
..............
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
 ...................


ref:
https://www.learnopencv.com/install-opencv3-on-ubuntu/
https://askubuntu.com/questions/720948/problems-installing-gfortran
https://github.com/opencv/opencv/issues/8622
https://askubuntu.com/questions/15433/unable-to-lock-the-administration-directory-var-lib-dpkg-is-another-process
https://askubuntu.com/questions/884413/unable-to-install-libgtk2-0-dev-on-ubuntu-16-04/886022

https://docs.opencv.org/trunk/d2/de6/tutorial_py_setup_in_ubuntu.html
https://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html

Tuesday, 20 March 2018

Problem with Spotify Keys


Problem:

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repository.spotify.com stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EFDC8610341D9410
W: Failed to fetch http://repository.spotify.com/dists/stable/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EFDC8610341D9410
W: Some index files failed to download. They have been ignored, or old ones used instead.

####################################################################3


This happen when somehow we'd lost the keys.
To solve i have executed the first step listed here https://www.spotify.com/de/download/linux/

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0DF731E45CE24F27EEEB1450EFDC8610341D9410


ref:
https://superuser.com/questions/932781/failed-to-fetch-spotify-repository-while-updating-ubuntu

Tuesday, 13 March 2018

Tinkering OpenWRT (5) : Build OpenWRT Source Code

Step 1: Inslall softwares
sudo apt-get install subversion g++ zlib1g-dev build-essential git python rsync man-db 
sudo apt-get install libncurses5-dev gawk gettext unzip file libssl-dev wget

Step 2: download source
git clone https://git.lede-project.org/source.git lede 
cd lede 

Step 3:
./scripts/feeds update -a 
./scripts/feeds install -a 

Step 4:
make menuconfig # Maximum the terminal when doing this.
More research needs to be done here to fit different systems. Here we compile for VirtualBox as an example.
      “Target System” ⇒ “x86”
      “Target Images” ⇒ “Build VirtualBox image files(VDI)”
Save and Exit.

Step 5: Compile
make
 make[1] world
 make[2] tools/compile
 make[3] -C tools/flock compile
 make[3] -C tools/sed compile
 make[3] -C tools/patch compile
 make[3] -C tools/xz compile
 make[3] -C tools/tar compile
 make[3] -C tools/m4 compile
 make[3] -C tools/autoconf compile
 make[3] -C tools/pkg-config compile
 make[3] -C tools/automake compile
 make[3] -C tools/missing-macros compile
 make[3] -C tools/libtool compile
 make[3] -C tools/gmp compile
 make[3] -C tools/mpfr compile
 make[3] -C tools/mpc compile
 make[3] -C tools/libelf compile
 make[3] -C tools/expat compile
 make[3] -C tools/flex compile
 make[3] -C tools/bison compile
 make[3] -C tools/mklibs compile
 make[3] -C tools/sstrip compile
 make[3] -C tools/make-ext4fs compile
 make[3] -C tools/e2fsprogs compile
 make[3] -C tools/mtd-utils compile
 make[3] -C tools/libressl compile
 make[3] -C tools/mkimage compile
 make[3] -C tools/firmware-utils compile
 make[3] -C tools/patch-image compile
 make[3] -C tools/findutils compile
 make[3] -C tools/quilt compile
 make[3] -C tools/padjffs2 compile
 make[3] -C tools/mm-macros compile
 make[3] -C tools/cmake compile
 make[3] -C tools/scons compile
 make[3] -C tools/bc compile
 make[3] -C tools/gengetopt compile
 make[3] -C tools/patchelf compile
 make[3] -C tools/mtools compile
 make[3] -C tools/dosfstools compile
 make[3] -C tools/qemu compile
 make[3] -C tools/lzma compile
 make[3] -C tools/squashfs4 compile
 make[2] toolchain/compile
 make[3] -C toolchain/gdb compile
 make[3] -C toolchain/binutils compile
 make[3] -C toolchain/gcc/initial compile
 make[3] -C toolchain/kernel-headers compile
 make[3] -C toolchain/musl compile
 make[3] -C toolchain/gcc/final compile
 make[3] -C toolchain/fortify-headers compile
 make[3] -C toolchain/yasm compile
 make[2] target/compile
 make[3] -C target/linux compile
 make[2] diffconfig
 make[2] package/cleanup
 make[2] package/compile
 make[3] -C package/libs/libubox host-compile
 make[3] -C package/system/opkg host-compile
 make[3] -C package/libs/toolchain compile
 make[3] -C package/libs/libnl-tiny compile
 make[3] -C package/libs/libjson-c compile
 make[3] -C package/utils/lua compile
 make[3] -C package/libs/libubox compile
 make[3] -C package/system/ubus compile
 make[3] -C package/system/uci compile
 make[3] -C package/network/config/netifd compile
 make[3] -C package/firmware/linux-firmware compile
 make[3] -C package/firmware/prism54-firmware compile
 make[3] -C package/kernel/linux compile
 make[3] -C package/system/ubox compile
 make[3] -C package/libs/ncurses host-compile
 make[3] -C package/libs/zlib compile
 make[3] -C package/libs/ncurses compile
 make[3] -C package/utils/util-linux compile
 make[3] -C package/system/fstools compile
 make[3] -C package/system/fwtool host-compile
 make[3] -C package/system/fwtool compile
 make[3] -C package/system/procd compile
 make[3] -C package/system/usign host-compile
 make[3] -C package/utils/jsonfilter compile
 make[3] -C package/system/lede-keyring compile
 make[3] -C package/system/usign compile
 make[3] -C package/base-files compile
 make[3] -C package/boot/grub2 host-compile
 make[3] -C package/boot/grub2 compile
 make[3] -C package/kernel/button-hotplug compile
 make[3] -C package/libs/mbedtls compile
 make[3] -C package/libs/ustream-ssl compile
 make[3] -C package/libs/uclient compile
 make[3] -C package/network/utils/iptables compile
 make[3] -C package/network/config/firewall compile
 make[3] -C package/network/ipv6/odhcp6c compile
 make[3] -C package/network/services/dnsmasq compile
 make[3] -C package/network/services/dropbear compile
 make[3] -C package/network/services/odhcpd compile
 make[3] -C package/libs/libpcap compile
 make[3] -C package/network/utils/linux-atm compile
 make[3] -C package/network/utils/resolveip compile
 make[3] -C package/network/services/ppp compile
 make[3] -C package/system/mtd compile
 make[3] -C package/system/opkg compile
 make[3] -C package/utils/busybox compile
 make[3] -C package/utils/e2fsprogs compile
 make[3] -C package/utils/f2fs-tools compile
 make[2] package/install
 make[2] target/install
 make[3] -C target/linux install
 make[2] package/index
 make[2] checksum

It took my T420 almost 2 hours to finish the first make...You can ultimately find the results in the bin file.

############################################3

Keep updated with the official website:
    https://openwrt.org/docs/guide-developer/quickstart-build-images


ref:
https://www.youtube.com/watch?v=kjzQg_sB8rY
https://openwrt.org/docs/guide-developer/quickstart-build-images!!!!!!
http://blog.csdn.net/gubenpeiyuan/article/details/8024247

Wednesday, 7 March 2018

Tinkering OpenWRT (6) : Connect Raspberry Pi to Computer with TTL-USB Converter FTDI

It must be frustrating to use a Pi as a new computer and give it all the peripherals like mouse and keyboards and most annoying one, an extra monitor. We can simply use the serial port to connect the Pi with Computer. Here is how.

Step 1:
Plug in the FTDI module and do:
       ls /dev/ttyUSB*
usually FTDI is mounted at ttyUSB0.

Step 2:
Conncet FTDI with your PI, I am using B+ model.




Step 3:
      screen /dev/ttyUSB0 115200

And voila!

BusyBox v1.23.2 (2016-01-31 10:28:42 CET) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 CHAOS CALMER (15.05.1, r48532)
 -----------------------------------------------------
  * 1 1/2 oz Gin            Shake with a glassful
  * 1/4 oz Triple Sec       of broken ice and pour
  * 3/4 oz Lime Juice       unstrained into a goblet.
  * 1 1/2 oz Orange Juice
  * 1 tsp. Grenadine Syrup
 -----------------------------------------------------
root@OpenWrt:/# [   19.795613] random: nonblocking pool is initialized

root@OpenWrt:/# 

Step 4: Blinky
root@OpenWrt:/# ls -1 /sys/class/leds/
led0

root@OpenWrt:/# echo 1 > /sys/class/leds/led0/brightness     // ? just blink?
root@OpenWrt:/# echo 1 > /sys/class/leds/led0/brightness     // ? just blink?
root@OpenWrt:/# echo 1 > /sys/class/leds/led0/brightness     // ? just blink?
root@OpenWrt:/# echo 0 > /sys/class/leds/led0/brightness     // off
root@OpenWrt:/# echo 1 > /sys/class/leds/led0/brightness     // NOW KELP ON ??!!!


ref:
http://caoyudong.com/2015/10/03/%E9%80%9A%E8%BF%87USB%E8%BD%AC%E4%B8%B2%E5%8F%A3%E6%A8%A1%E5%9D%97%E8%BF%9E%E6%8E%A5%E6%A0%91%E8%8E%93%E6%B4%BE/
http://ediy.com.my/index.php/tutorials/item/131-openwrt-control-led-manually
http://hacklabos.org/2014/04/playing-with-gpio-and-sensors-on-openwrt/

Sunday, 4 March 2018

Tinkering OpenWRT (4) : make config

When I tried to configure my make config menu for openwrt, I got:

Your display is too small to run Menuconfig!
It must be at least 19 lines by 80 columns.
/home/boris/workspace/openWRT/WRTKernel/source/include/toplevel.mk:136: recipe for target 'menuconfig' failed
make: *** [menuconfig] Error 1

Don't worry, this simply means you have to maximize your terminal window.