forked from WaqasSultani/AnomalyDetectionCVPR2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_binary_blob.m
24 lines (19 loc) · 840 Bytes
/
read_binary_blob.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
%
% Licensed under the Creative Commons Attribution-NonCommercial 3.0
% License (the "License"). You may obtain a copy of the License at
% https://creativecommons.org/licenses/by-nc/3.0/.
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
% License for the specific language governing permissions and limitations
% under the License.
%
function [s, data] = read_binary_blob(fn)
f = fopen(fn, 'r');
s = fread(f, [1 5], 'int32');
% s contains size of the blob e.g. num x chanel x length x height x width
m = s(1)*s(2)*s(3)*s(4)*s(5);
% data is the blob binary data in single precision (e.g float in C++)
data = fread(f, [1 m], 'single');
fclose(f);
end