Sunday, September 1, 2013

How to highlight cuda code in visual studio 10.0


Step 1: go to the following path
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\doc\syntax_highlighting\visual_studio_7
You will find two files:
readme.txt
usertype.dat

Step 2: Following the instruction in 'readme.txt', 
a) Copy 'usertype.dat' file to the following path
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE

b) Add cuda extension '.cu' and '.cuh' via
Select the menu "Tools->Options...".  Open "Text Editor" in the tree view on the left, and click on "File Extension".  Type cu in the "Extension" box, set the editor to "Microsoft Visual C++" and click "Add".  Click "OK" on the dialog box. 

c) Restart Visual Studio and your CUDA code should now have syntax highlighting.

Monday, August 19, 2013

How to use python to load opencv yml file




from cv2 import cv
import numpy as np

filepath = "test.yml"
matrixA = np.array( cv.Load(filepath, cv.CreateMemStorage(), "matrixA") )
matrixB = np.array( cv.Load(filepath, cv.CreateMemStorage(), "matrixB") )
print "matrixA:", matrixA
print "matrixB:", matrixB

# The following is the "test.yml" file
#======================================================================
# %YAML:1.0
# matrixA: !!opencv-matrix
#    rows: 2
#    cols: 5
#    dt: f
#    data: [ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9. ]
# matrixB: !!opencv-matrix
#    rows: 3
#    cols: 4
#    dt: f
#    data: [ 5.00000000e-001, 1.50000000e+000, 2.50000000e+000,
#        3.50000000e+000, 4.50000000e+000, 5.50000000e+000,
#        6.50000000e+000, 7.50000000e+000, 8.50000000e+000,
#        9.50000000e+000, 1.05000000e+001, 1.15000000e+001 ]
#======================================================================













Saturday, July 27, 2013

Matlab: Convert GIF image to BMP/JPG image

[img map] = imread('mypic.gif');
if ~isempty(map), img = ind2rgb(img, map); end
imshow(img);

% imwrite(img, 'mypic.jpg');
% imwrite(img, 'mypic.bmp');