>

2016년 9월 4일 일요일

Using OpenCV3.x in OpenFrameworks0.9.3, Mac OS X

0. Well, you need to install opencv3.1 somewhere in your computer. In my case, I installed it in /usr/local/ocv3 because I have opencv2.x version previously installed. All the opencv3.x files are in /usr/local/ocv3.

1. In your Xcode project, find the file Project.xconfig, and put the search path as shown in the image below.

2. Likewise, put the library files in the opencv3 folder, which was created by yourself.


3. Now, you can use opencv in openframeworks.


In the following, 
 - An image named 'bikers.jpg' is loaded into bikersImage, which is an instance of ofImage
 - The image information of bikersImage  is put into cvImg, which is an instance of cv::Mat
 - In ofApp::update() function, some image processing is applied to cvImg. In this case cv::blur() enforces box filtering.
 - To display the filtered result on the screen, you need bikersImage.update(), which updates its texture memory for display. 
 - In ofApp::display() function, the command bikersImage.update(0,0) will show you a very much blurred image, I am sure.


EOF

2016년 8월 29일 월요일

Simple Setup: ssh login without password from Mac to Linux


Step 1. In your Mac computer. Use terminal of course.

$ ssh-keygen 

Some questions will be provided. Just press Enter key.

Step 2. Copy ~/.ssh/id_rsa.pub to Linux

$ cat ~/.ssh/id_rsa.pub | ssh user_id@your.linux.machine "umask 077; mkdir -p .ssh ; cat >> .ssh/authorized_keys"

You will be asked to provide password for user_id@your.linux.machine.

Step 3. ssh login to Linux machine without password.

$ ssh your.linux.machine

Done.

2016년 8월 17일 수요일

ssh X11 Forwarding Ubuntu Server Setting


$ sudo vi /usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf 
  1 [SeatDefaults]
  2 # Dump core
  3 xserver-command=X -core

  4 xserver-allow-tcp=true

* At the client side (Not sure if X11 needs be run before the followings)
$ xhost +
$ ssh -X user@ubuntu.host

2016년 2월 4일 목요일

Installing OpenCV 3.1, Qt5.5

date: 2015.02.05

Qt5.5

update: Cuda, NVIDIA Web Driver.

[ 25%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o
nvcc fatal   : The version ('70002') of the host compiler ('Apple clang') is not supported
CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:206 (message):
  Error generating
  /Users/yndk/Desktop/github/opencv/myBuild-make/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o


NVIDIA compilation is not compatible with OS X El Capitane.
There is a way.

https://devtalk.nvidia.com/default/topic/879431/nvcc-amp-clang-7-no-typo-here-

But, I don't like it.

So disable CUDA.


Done.



2015년 7월 22일 수요일

OpenCV 3.0.0 in Yosemitte 10.10.x

Source: 
http://www.learnopencv.com/install-opencv-3-on-yosemite-osx-10-10-x/

git clone https://github.com/Itseez/opencv_contrib.git
cd opencv_contrib
git checkout tags/3.0.0


* with CUDA 7.0 (otherwise errors or setting changes)

cmake -D WITH_CUDA=OFF -D CMAKE_INSTALL_PREFIX=/full/path/to/opencv/build -D CMAKE_BUILD_TYPE=RELEASE   ..

---
cp lib/pkgconfig/opencv.pc /usr/local/lib/pkgconfig/opencv3.pc

---
cd /full/path/to/opencv/samples/cpp
 
# If you built it with no CUDA support or with CUDA 7 or above
g++ -ggdb `pkg-config --cflags --libs opencv3` facedetect.cpp -o /tmp/test && /tmp/test
 
---
export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/cuda/lib/:$DYLD_FALLBACK_LIBRARY_PATH
cd /full/path/to/opencv/samples/gpu
 
# If you built it with CUDA 7 or above
g++ -ggdb `pkg-config --cflags --libs opencv3` hog.cpp -o /tmp/hog && /tmp/hog
 

2015년 4월 8일 수요일

glm::mat has internally column major representation.

$ brew install glm
----------------------------
glm test code.
----------------------------
  • Each row and column in glm::mat4 is zero-based:
    
        glm::mat4 m4( 1.0f ); // construct identity matrix
        m4[ 0 ]     // column zero
        m4[ 0 ].x   // same as m4[ 0 ][ 0 ]
        m4[ 0 ].y   // same as m4[ 0 ][ 1 ]
        m4[ 0 ].z   // same as m4[ 0 ][ 2 ]
        m4[ 0 ].w   // same as m4[ 0 ][ 3 ]
    
    
  • Each column of matrix glm::mat4 is a vec4.
  • To set the entire column, e.g. for translation,
    
        glm::mat4 m4( 1.0f ); // construct identity matrix
        m4[ 3 ] = glm::vec4( vec3( x, y, z ), 1.0f );
    
    


1:  #include <iostream>  
2:  using namespace std;  
3:  // Include GLM  
4:  #include <glm/glm.hpp>  
5:  #include <glm/gtc/matrix_transform.hpp>  
6:  #include <glm/gtc/type_ptr.hpp>  
7:  #include <glm/gtx/transform.hpp>  
8:  #include <glm/gtx/string_cast.hpp>  
9:  #include <math.h>  
10:  float deg2rad(float deg) { return deg*M_PI/180.; }  
11:  void print (glm::mat3 r, string s)  
12:  {  
13:      cout << s << endl;  
14:      for (int i=0; i<3; i++) {  
15:          for (int j=0; j<3; j++) {  
16:              cout << " " << r[i][j] ;  
17:          }  
18:          cout << endl;  
19:      }  
20:  }  
21:  void print (const glm::mat4 &r, string s)  
22:  {  
23:      cout << s << endl;  
24:      for (int i=0; i<4; i++) {  
25:          for (int j=0; j<4; j++) {  
26:              cout << " " << r[i][j] ;  
27:          }  
28:          cout << endl;  
29:      }  
30:  }  
31:  void print(const glm::vec3& v, string s)  
32:  {  
33:      cout << s << endl;  
34:      for (int i=0; i<3; i++) {  
35:          cout << " " << v[i] ;  
36:      }  
37:      cout << endl;  
38:  }  
39:  int main()  
40:  {  
41:   float degree = 45.;  
42:   glm::vec3 zAxis(0.f, 0.f, 1.f);  
43:   glm::mat3 R3 = glm::mat3(glm::rotate (deg2rad(degree),zAxis));  
44:   glm::mat4 R4 = glm::rotate (deg2rad(degree),zAxis);  
45:   cout << "Note that glm matrices are stored in column major order!" << endl;  
46:   cout << "----" << endl;  
47:   print(R3, "R3");  
48:   printf("----\n");  
49:   cout << "The following will show you column vectors enclosed by parantheses." << endl;  
50:   cout << "R3: " << glm::to_string(R3) << endl;  
51:   printf("----\n");  
52:   print(R4, "R4");  
53:   printf("----\n");  
54:   glm::vec2 p(1,0), q(0,1);  
55:   glm::vec3 u(1,1,1);  
56:   glm::vec3 ru = R3 * u,  
57:        rp = R3 * glm::vec3(p,1),  
58:        rq = R3 * glm::vec3(q,1);  
59:   printf("This is the 1st column of R3.\n");  
60:   print(rp, "rp:");  
61:   printf("----\n");  
62:   printf("This is the 2nd column of R3.\n");  
63:   print(rq, "rq:");  
64:   printf("----\n");  
65:   printf("This is the 45 degrees rotation result of (1,1,1) about the z-axis.\n");  
66:   print(ru, "ru:");  
67:   printf("----\n");  
68:   glm::mat3 H(1.0); // identity matrix  
69:   H[2].x = 1.0; // (0,2)-element of H  
70:   cout << "H: " << glm::to_string(H) << endl;  
71:   H[2] = glm::vec3(2.0f, 3.0f, 1.0f); // 2d translation  
72:   cout << "H: " << glm::to_string(H) << endl;  
73:   glm::mat3 T = H * R3;  
74:   cout << "H*R: " << glm::to_string(T) << endl;  
75:   return 0;  
76:  }  
77:  // EOF //  

2015년 3월 24일 화요일

OpenGL-tutorial_v0014_33, Tutorial-01 Mac OS X

1. download
2. brew install glew glfw3 glm
3. Tutorial-01
 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

 $ clang++ tutorial01.cpp -I /usr/local/include/GLFW -lglfw3 -framework opengl -lglew

4.
 $ clang++ -I /usr/local/include/GLFW -I .. -lglfw3 -framework opengl -lglew ../common/shader.cpp  tutorial02.cpp