Friday, December 5, 2014
Tuesday, November 4, 2014
Friday, October 3, 2014
Installing OpenCV in Linux
Install dependecies:
$sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev
$mkdir OpenCV
$cd OpenCV
$git clone https://github.com/Itseez/opencv.git
$cmake CMakeLists.txt
$make
$sudo make install
Make a file under /etc.ld.so.conf.d folder. Name it opencv.conf
Write /usr/local/lib/ and save the file.
$sudo gedit /etc/ld.so.conf.d/opencv.conf
$sudo ldconfig -v
Set the system variables:
$export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
$sudo ldconfig
$export LD_LIBRARY_PATH=~/opencv/OpenCV-2.0.3/release/:$LD_LIBRARY_PATH
$sudo ldconfig
$sudo gedit /etc/bash.bashrc
Type this to the last line of bash.bashrc:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
$sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev
$mkdir OpenCV
$cd OpenCV
$git clone https://github.com/Itseez/opencv.git
$cmake CMakeLists.txt
$make
$sudo make install
Make a file under /etc.ld.so.conf.d folder. Name it opencv.conf
Write /usr/local/lib/ and save the file.
$sudo gedit /etc/ld.so.conf.d/opencv.conf
$sudo ldconfig -v
Set the system variables:
$export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
$sudo ldconfig
$export LD_LIBRARY_PATH=~/opencv/OpenCV-2.0.3/release/:$LD_LIBRARY_PATH
$sudo ldconfig
$sudo gedit /etc/bash.bashrc
Type this to the last line of bash.bashrc:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
Wednesday, October 1, 2014
Installing LIBLAS in Linux
Start with installing GDAL, Libgeotiff and Laszip libraries which will be necessary to build LIBLAS.
Installing GDAL (this might take an hour):
$sudo apt-get install build-essential python-all-dev
$wget http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz
$tar xvfz gdal-1.9.0.tar.gz
$cd gdal-1.9.0
$./configure --with-python
$make
$sudo make install
Installing Libgeotiff:
sudo apt-get install proj proj-bin proj-data libproj-dev libtiff4-dev libgeotiff-dev libgdal1-dev gdal-bin python-gdal libgdal1-1.7.0
Installing Laszip:
cd /opt/source
wget http://download.osgeo.org/laszip/laszip-2.1.0.tar.gz
tar xvfz laszip-2.1.0.tar.gz
cd laszip-2.1.0
mkdir build
mkdir cmake_build
cd cmake_build
# run cmake
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/source/laszip-2.1.0/build
# compile
make -j$threads
# install into build dir
make install
Finally now you can download LIBLAS source codes and install by typing:
$ git clone git://github.com/libLAS/libLAS.git liblas
$ cd liblas
$ mkdir makefiles
$ cd makefiles
$ cmake -G "Unix Makefiles" ../
$ make
Installing GDAL (this might take an hour):
$sudo apt-get install build-essential python-all-dev
$wget http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz
$tar xvfz gdal-1.9.0.tar.gz
$cd gdal-1.9.0
$./configure --with-python
$make
$sudo make install
Installing Libgeotiff:
sudo apt-get install proj proj-bin proj-data libproj-dev libtiff4-dev libgeotiff-dev libgdal1-dev gdal-bin python-gdal libgdal1-1.7.0
Installing Laszip:
cd /opt/source
wget http://download.osgeo.org/laszip/laszip-2.1.0.tar.gz
tar xvfz laszip-2.1.0.tar.gz
cd laszip-2.1.0
mkdir build
mkdir cmake_build
cd cmake_build
# run cmake
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/source/laszip-2.1.0/build
# compile
make -j$threads
# install into build dir
make install
Finally now you can download LIBLAS source codes and install by typing:
$ git clone git://github.com/libLAS/libLAS.git liblas
$ cd liblas
$ mkdir makefiles
$ cd makefiles
$ cmake -G "Unix Makefiles" ../
$ make
Wednesday, September 17, 2014
Compile the first PCL code on linux (write pcd)
Source code:
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
int
main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ> cloud;
// Fill in the cloud data
cloud.width = 5;
cloud.height = 1;
cloud.is_dense = false;
cloud.points.resize (cloud.width * cloud.height);
for (size_t i = 0; i < cloud.points.size (); ++i)
{
cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
}
pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;
for (size_t i = 0; i < cloud.points.size (); ++i)
std::cerr << " " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;
return (0);
}
make CMakeLists.txt file which contains:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(pcd_write)
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (pcd_write pcd_write.cpp)
target_link_libraries (pcd_write ${PCL_LIBRARIES})
> cmake CMakeLists.txt
> make
> ./pcd_write
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
int
main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ> cloud;
// Fill in the cloud data
cloud.width = 5;
cloud.height = 1;
cloud.is_dense = false;
cloud.points.resize (cloud.width * cloud.height);
for (size_t i = 0; i < cloud.points.size (); ++i)
{
cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
}
pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;
for (size_t i = 0; i < cloud.points.size (); ++i)
std::cerr << " " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;
return (0);
}
make CMakeLists.txt file which contains:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(pcd_write)
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (pcd_write pcd_write.cpp)
target_link_libraries (pcd_write ${PCL_LIBRARIES})
> cmake CMakeLists.txt
> make
> ./pcd_write
Install Qt on Linux (Ubuntu)
chmod +x qt-opensource-linux-x64-1.6.0-5-online.run
./qt-opensource-linux-x64-1.6.0-5-online.run
Pop-up screen will appear!
Select .pro extension project file and apply settings you want.
Tuesday, September 16, 2014
Compile and Call HelloWorld with G++
compile main.cpp:
g++ -Wall -W -Werror main.cpp -o MyHelloWorld (gcc is C compiler, g++ is C++ compiler)
OR
g++ main.cpp
It generates "a.out"
Call the program;
./a.out
g++ -Wall -W -Werror main.cpp -o MyHelloWorld (gcc is C compiler, g++ is C++ compiler)
OR
g++ main.cpp
It generates "a.out"
Call the program;
./a.out
Installing PCL on Ubuntu
sudo apt-get install cmake (if cmake is not installed yet)
sudo apt-get update
sudo apt-get install git (if git is not installed yet)
git clone https://github.com/PointCloudLibrary/pcl.git pcl-trunk
ln -s pcl-trunk pcl
mkdir release
(Go to PCL Folder)
cmake -DCMAKE_BUILD_TYPE=NONE -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON
make
sudo make install
sudo apt-get update
sudo apt-get install git (if git is not installed yet)
git clone https://github.com/PointCloudLibrary/pcl.git pcl-trunk
ln -s pcl-trunk pcl
mkdir release
(Go to PCL Folder)
cmake -DCMAKE_BUILD_TYPE=NONE -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON
make
sudo make install
Friday, August 8, 2014
Call C++ Function in Matlab
mex -setup %choose compiler
mex mycode.c %call the function
If you need to add other cpp files and lib files while compiling in Matlab:
mex cpp-file-for-matlab.cpp ../addthis.cpp ../addthat.cpp -laddlibrary
mex mycode.c %call the function
If you need to add other cpp files and lib files while compiling in Matlab:
mex cpp-file-for-matlab.cpp ../addthis.cpp ../addthat.cpp -laddlibrary
Tuesday, August 5, 2014
PCL Concavehull Fails
...with message saying "The initial hull is narrow (cosine of min. angle is 0.999999999999998). A coplanar point may lead to a wide facet..."
It stops complaining when I set the concavehull dimensions to 2, instead of letting the function decide by itself. It is done by adding the following line;
chull.setDimension(2);
Friday, August 1, 2014
Write C++ Code Process Time on Console
#include <time.h>
time_t start,end;
time (&start);
.
.
.
<code>
.
.
.
time (&end);
double dif = difftime (end,start);
cout<< "Elasped time is " << dif <<" seconds." << "\n" << endl;
File Cannot Be Found - Lovely Crash
...instead of crashing without any error messages
std::ifstream ifs (mystr, std::ios::in | std::ios::binary);
if (ifs.is_open()) {
cout<<"The file is read successfully! :)"<<endl;}
else {
// show message:
cout << "Error opening file!"<<endl;
cout << "The file cannot be found in the given path."<<endl;
cout<< "The program will be closed." <<endl;
system("PAUSE") ;
exit(EXIT_FAILURE);
}
std::ifstream ifs (mystr, std::ios::in | std::ios::binary);
if (ifs.is_open()) {
cout<<"The file is read successfully! :)"<<endl;}
else {
// show message:
cout << "Error opening file!"<<endl;
cout << "The file cannot be found in the given path."<<endl;
cout<< "The program will be closed." <<endl;
system("PAUSE") ;
exit(EXIT_FAILURE);
}
Add Environment Variables in C++ Code
char *shell;
/* Get the path of the current shell to start it later */
shell = getenv("SHELL");
if (shell == NULL) {
fprintf(stderr, "Error eding SHELL env. var.\n");
return 1;
}
/* Overwrite env. var. PATH */
if (setenv("PATH", "/usr/bin", 1) < 0) {
fprintf(stderr, "Error setting env. var.\n");
return 1;
}
Check also: http://linuxconfig.org/set-and-get-environmental-shell-variable-using-c
Thursday, July 31, 2014
Saving EPS Images in Matlab
Matlab imwrite function does not work for saving EPS format (though some comments on internet say that it is possible by sending the color values to a colormap). One very simple solution is using;
im = imread('image.png');
figure, imshow(im);
print -depsc image2.eps
im = imread('image.png');
figure, imshow(im);
print -depsc image2.eps
Subscribe to:
Comments (Atom)
Setting Jupyter and Tensorflow on Google Cloud Platform
https://towardsdatascience.com/running-jupyter-notebook-in-google-cloud-platform-in-15-min-61e16da34d52
-
Choosing using GPU/CPU/multi-GPU/parallel-cluster: trainingoptions(); Documenting the properties of the available GPU: gpuDevice; h...
-
https://towardsdatascience.com/running-jupyter-notebook-in-google-cloud-platform-in-15-min-61e16da34d52
-
You can build a dockerfile $docker build -t some-arbitrary-label You can cleanup your machine using; $docker rmi some-arbitrary-label...