open source pkg v1
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
% for easier readibility write them row by row
|
||||
function writeMatrixBin(fileID, M, type)
|
||||
|
||||
% 4 bytes each for the description
|
||||
fwrite(fileID, size(M,1), 'uint');
|
||||
fwrite(fileID, size(M,2), 'uint');
|
||||
fwrite(fileID, type, 'uint');
|
||||
|
||||
% Convert the matrix to OpenCV format (row minor as opposed to column
|
||||
% minor)
|
||||
M = M';
|
||||
|
||||
% type 0 - uint8, 1 - int8, 2 - uint16, 3 - int16, 4 - int, 5 -
|
||||
% float32, 6 - float64
|
||||
|
||||
% Write out the matrix itself
|
||||
|
||||
switch type
|
||||
case 0
|
||||
type = 'uint8';
|
||||
case 1
|
||||
type = 'int8';
|
||||
case 2
|
||||
type = 'uint16';
|
||||
case 3
|
||||
type = 'int16';
|
||||
case 4
|
||||
type = 'int';
|
||||
case 5
|
||||
type = 'float32';
|
||||
case 6
|
||||
type = 'float64';
|
||||
otherwise
|
||||
type = 'float32';
|
||||
end
|
||||
fwrite(fileID, M, type);
|
||||
end
|
||||
@@ -0,0 +1,28 @@
|
||||
function [ success ] = write_lin_dyn_svm( location, means, w, b, pos_lbl, neg_lbl)
|
||||
%WRITE_LIN_SVR Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
|
||||
fileID = fopen(location, 'w');
|
||||
|
||||
if(fileID ~= -1)
|
||||
|
||||
% Write the regressor type 5 - linear dynamic SVM
|
||||
fwrite(fileID, 5, 'uint');
|
||||
|
||||
writeMatrixBin(fileID, means, 6);
|
||||
writeMatrixBin(fileID, w, 6);
|
||||
fwrite(fileID, b, 'float64');
|
||||
|
||||
fwrite(fileID, pos_lbl, 'float64');
|
||||
fwrite(fileID, neg_lbl, 'float64');
|
||||
|
||||
fclose(fileID);
|
||||
|
||||
success = true;
|
||||
|
||||
else
|
||||
success = false;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
function [ success ] = write_lin_dyn_svr( location, means, w, b, cutoff)
|
||||
%WRITE_LIN_SVR Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
|
||||
fileID = fopen(location, 'w');
|
||||
|
||||
if(fileID ~= -1)
|
||||
|
||||
% Write the regressor type 1 - linear dynamic SVR
|
||||
fwrite(fileID, 1, 'uint');
|
||||
|
||||
fwrite(fileID, cutoff, 'float64');
|
||||
|
||||
writeMatrixBin(fileID, means, 6);
|
||||
writeMatrixBin(fileID, w, 6);
|
||||
fwrite(fileID, b, 'float64');
|
||||
|
||||
fclose(fileID);
|
||||
|
||||
success = true;
|
||||
|
||||
else
|
||||
success = false;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
function [ success ] = write_lin_svm( location, means, w, b, pos_lbl, neg_lbl)
|
||||
%WRITE_LIN_SVR Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
|
||||
fileID = fopen(location, 'w');
|
||||
|
||||
if(fileID ~= -1)
|
||||
|
||||
% Write the regressor type 4 - linear SVM
|
||||
fwrite(fileID, 4, 'uint');
|
||||
|
||||
writeMatrixBin(fileID, means, 6);
|
||||
writeMatrixBin(fileID, w, 6);
|
||||
fwrite(fileID, b, 'float64');
|
||||
|
||||
fwrite(fileID, pos_lbl, 'float64');
|
||||
fwrite(fileID, neg_lbl, 'float64');
|
||||
|
||||
fclose(fileID);
|
||||
|
||||
success = true;
|
||||
|
||||
else
|
||||
success = false;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
function [ success ] = write_lin_svr( location, means, w, b)
|
||||
%WRITE_LIN_SVR Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
|
||||
fileID = fopen(location, 'w');
|
||||
|
||||
if(fileID ~= -1)
|
||||
|
||||
% Write the regressor type 0 - linear SVR
|
||||
fwrite(fileID, 0, 'uint');
|
||||
|
||||
writeMatrixBin(fileID, means, 6);
|
||||
writeMatrixBin(fileID, w, 6);
|
||||
fwrite(fileID, b, 'float64');
|
||||
|
||||
fclose(fileID);
|
||||
|
||||
success = true;
|
||||
|
||||
else
|
||||
success = false;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user