Monday, May 18, 2015

Read Matlab File Into LMDB/LevelDB

I found current Caffe lacking this functionality to read Matlab .mat file (of arbitrary channels, not restricted to RGB) into LMDB/LevelDB, and was motivated to write an extension for this:

convert_mat.cpp

To use it, put it under Caffe_directory/tools, and include proper Matlab headers and libraries in Caffe Makefile. I also included an example of the CMakeLists.txt:

CMakeLists.txt 

This works for Mac. Under linux, the matlab path would probably be

-I/opt/matlab/extern/include
-L/opt/matlab/bin/glnxa64

Hope this small piece of code would be helpful.

Thursday, May 14, 2015

Reading .mat file in C++

The CMakeLists.txt:

cmake_minimum_required(VERSION 3.1)
project(mat2lmdb_cpp)

include_directories(/Applications/MATLAB_R2015a.app/extern/include)
link_directories(/Applications/MATLAB_R2015a.app/bin/maci64)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lmx -lmat")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")

set(SOURCE_FILES    convert_mat.cpp)

add_executable(mat2lmdb_cpp ${SOURCE_FILES})

Before you run, add the following:

export MATLAB="/Applications/MATLAB_R2015a.app"
export DYLD_LIBRARY_PATH=$MATLAB/bin/maci64/:DYLD_LIBRARY_PATH

Wednesday, May 13, 2015

A Quick Look at How to Mount SFTP Drive on Mac

1. Install macfuse.
2. Install sshfs
3. Mount using:

sshfs -o defer_permissions -o ServerAliveInterval=10 harryyang@***.***.edu:/ /Users/temp/sshfs2

Unmount

umount -f /Users/temp/sshfs

Thursday, May 7, 2015

Git switch branch

1. initialize from remote
git clone

2. update:
git pull

3. new branch:
git branch iss53
git checkout iss53

4. pull remote changes:
git reset --hard HEAD
git pull

Wednesday, May 6, 2015

CMakeLists Example

cmake_minimum_required(VERSION 3.1)
project(WebRun)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
include_directories(revlib/include include)
set(SOURCE_FILES main.cpp) add_executable(WebRun ${SOURCE_FILES}) TARGET_LINK_LIBRARIES(WebRun libboost_system.a libboost_filesystem.a libsqlite3.a)

Another example:

cmake_minimum_required(VERSION 3.1)
project(Occlusion)
find_package(PCL 1.3 REQUIRED COMPONENTS common io octree surface)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")

set(SOURCE_FILES    main.cpp)

add_executable(Occlusion ${SOURCE_FILES})
target_link_libraries(Occlusion ${PCL_LIBRARIES})