Code covered by the BSD License  

4.83333
4.8 | 6 ratings Rate this file 114 Downloads (last 30 days) File Size: 2.8 KB File ID: #33863 Version: 1.4

Histograms of Oriented Gradients

by

Leo (view profile)

 

21 Nov 2011 (Updated )

mex function for calculating histograms of (oriented) gradients (Dalal & Triggs CVPR 2005).

| Watch this File

File Information
Description

A mex function for calculating histograms of (oriented) gradients as described in the paper "Histograms of Oriented Gradients for Human Detection"[1]:

http://lear.inrialpes.fr/pubs/2005/DT05/

Function can be called with either one or two arguments :

hogs = HoG(Image,Params);
or
hogs = HoG(Image);

Params should be a size 5 vector with:

Params(0) = number of orientation bins.
Params(1) = cell size.
Params(2) = block size.
Params(3) = 1 for oriented gradients and 0 otherwise.
Params(4) = value for clipping of the L2-norm.

See [1] for more details on these values.

If the function is called with only one parameter then the default values are used:

Params = [9 8 2 0 0.2];

Function can be called for both a RGB and grayscale image.

The function only supports data of type double, image data should first be cast into double i.e. HoG(double(Image)).

Finally [1] mentions the possibility of downweighting "pixels near the edges
of the block by applying a Gaussian spatial window..." and that this leads to and increase in performance of 1% at 10^-4 FPPW. This downweighting scheme is not used by this function.

The HoG function code is part of the MASH public descriptors ("heuristics"):

http://mash-project.eu/

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (44)
25 Mar 2015 farah

farah (view profile)

The following error comes while running this code
Error using HOG
Too many input arguments.

Error in HOG (line 9)
HOGv = HOG(I,[orientation_bins, cell_size, block_size, oriented_gradients, clipping_L2norm]);

Error in detect (line 23)
featureVector{fcount} = HOG(double(img));

Error in demo (line 40)
detect(img,model,tSize);

Comment only
02 May 2014 san faten

Hi,I'd like to repeat Raul's unanswered question.
"I want to use HOG with SVM. Your code returned different size's of vector's for different images. But, to train the features with SVM, the vector's must be in the same size."
is there any suggestion how can we change the code so that we can use it with the SVM? thx in advance

Comment only
30 Mar 2014 Yuval Aviel

the first option is the correct one:
histImg = reshape(hog, [Params(1) nCells nCells]);

Comment only
24 Mar 2014 Yuval Aviel

Hi Leo, I'd like to repeat victorp's unanswered question:
"could you tell me how to fold the output vector back (to 3D)?"

in particular, considering the following code:

Params = [9 4 1 0 0.2]; hogs = HoG(Image,Params);
nCells = sqrt(length(hogs)/Params[1]) % (assuming square Image)

should it be:
histImg = reshape(hog, [Params(1) nCells nCells]);

or

histImg = reshape(hog, [nCells nCells Params(1)]);

??
Thanks,
yuval

Comment only
28 Feb 2014 A. Sanny

Hi Leo. I'm new and not well-known about this topic thus I need some help. Can you please explain the part about interpolation? In the paper it says "votes are interpolated bilinearly between the neighbouring bin centres in both orientation and position" and the code says "trilinear interpolation". Are there any improvement you made on Dalal-Triggs paper? Thank you :)

Comment only
01 Jan 2014 farah

farah (view profile)

I am trying to run the code by using mex HoG on the matlab command prompt but it is giving me errors like processor error: HOG.cpp:4 Could not find include file <vector>
Error HOG.cpp: 5 syntax error; found `namespace' expecting `;'
Error HOG.cpp: 5 syntax error; found `std' expecting `;'
Error HOG.cpp: 30 undeclared identifier `vector'
Error HOG.cpp: 30 illegal expression
Error HOG.cpp: 30 illegal expression
Error HOG.cpp: 30 illegal expression
Error HOG.cpp: 30 illegal expression
Error HOG.cpp: 30 found `int' expected a function
Error HOG.cpp: 30 illegal expression
Error HOG.cpp: 30 operands of > have illegal types `int' and `void'
Error HOG.cpp: 31 illegal expression
Error HOG.cpp: 31 illegal expression
Error HOG.cpp: 31 illegal expression
Error HOG.cpp: 31 illegal expression
Error HOG.cpp: 31 found `int' expected a function
Error HOG.cpp: 31 illegal expression
Error HOG.cpp: 31 operands of > have illegal types `int' and `void'
Error HOG.cpp: 35 syntax error; found `unsigned' expecting `;'
Error HOG.cpp: 35 syntax error; found `unsigned' expecting `;'
Error HOG.cpp: 35 too many errors .

I am using matlab version 13a

Comment only
18 Aug 2013 Fei

Fei (view profile)

Hi, Leo, thank you for your nice work. I have a question about the output. Suppose that I have 12*12 image and I use 9 bin 6 cell and 2*2 block, the output will be 36-D features. Could you tell me what is the order of the output?

14 Aug 2013 Sina

Sina (view profile)

Does this function work for 3d images? like a 3d brain image?

Comment only
19 Mar 2013 victorp

Leo, thanks lot!

Comment only
18 Mar 2013 Leo

Leo (view profile)

Hi Victor,

It is a bit difficult to comment on the VL code as it isnt mine, but I think the difference comes from how the normalization of the cells on the boundary is treated.

The cells on the left and bottom boundary only belong to two blocks (or in some cases one). For example there is no block starting at a cell on the left boundary and extending to the left as that would take it outside the image. Thus a 256x256 image only has 63*63 blocks of size 2x2.

If I understand the VL code correctly ,hog.c line 927 and onward, it assumes that every cell belongs to 4 blocks. For the case of boudary cells, where this assumption does not hold, certain block normalization schemes are simply repeated to make up the four blocks, see lines 932-935. So if I am correct, for boundary cells, there should be repetitions in the final descriptor of the VL code. Though obviously you shouldnt cite me on this :)

Hope this helps.

Leo

Comment only
17 Mar 2013 victorp

Hi Leo,

i'm trying to use your code. For an image of size 256x256, with default parameters i'm obtaining a vector of size - 142884 (63*63*9*4). However, using the vl_hog function (from VLFeat.org) with the same parameters im getting a vector of size-147456 (64*64*9*4). Could you clarify this? Furthermore, could you tell me for example how to fold the output vector back (as 3D) in case of signed case. Thanks,
Best regards,
V.

06 Mar 2013 Bhagyalekshmi

how to write it in matlab
plz help to run the code in matlab

Comment only
03 Mar 2013 Gaurav Bhosale

Hi Leo..do u have MATLAB code for HOG descriptor??

Comment only
29 Jan 2013 Leo

Leo (view profile)

Hi Anas,

I am afraid tracking isnt my field soI dont really know. It would depend a lot on the resolution of the camera andhow many fps you want to process. In general HoGs are computationally expensive so I wouldn't be suprised if simpler descriptors are used in practice.

Leo

Comment only
28 Jan 2013 Anas A.Salam

hello Leo how are you ??
i have a question about your work, could i use it with video in real time ?? i want to detect the human with security camera for example so could i do that ??

Comment only
04 Dec 2012 Hend K.

Hi Leo,
That was really helpful thank you very much

Comment only
04 Dec 2012 Leo

Leo (view profile)

Hi Hend,

Sorry for the late reply. There is overlapping between the blocks. Each block is shifted 1 cell to the right from the previous one.

Leo

Comment only
29 Nov 2012 Hend K.

Hi Leo,
thank you for your fast reply. I have one more question as I read your code I noticed that there is no overlapping between the blocks is that right?

Comment only
26 Nov 2012 Leo

Leo (view profile)

Hi Hend,

For the normalization scheme the L2 norm is used. If you want to change normalization schemes you could change lines 147 and 168 :

block_norm+=h[y+i][x+j][k]*h[y+i][x+j][k];

By 1 for oriented gradients and 0 otherwise I mean 1 for signed gradients and 0 for unsigned gradients.

Hope this helps.

Leo

Comment only
26 Nov 2012 Hend K.

Regarding the parameters, how to set:
1. unsigned gradients (0°-180°) or signed gradients (0°-360°)
2. normalization scheme, I guess only L2-norm is used?

and what do you mean by 1 for oriented gradients and 0 otherwise?

18 Sep 2012 Raul

Raul (view profile)

Hi, I have one question.
I want to use HOG with SVM. Your code returned different size's of vector's for different images. But, to train the features with SVM, the vector's must be in the same size.
How can I solve this problem?
Sorry for my bad english, I'm Brazilian.

10 Sep 2012 Hend K.

Thank you for sharing.
I got this error message:
atan2: DOMAIN error
because of the division by zero, could you please fix it. the histogram is computed and it doesn't contain any strange NAN's etc but the message is annoying.

Comment only
04 Sep 2012 Artium

Artium (view profile)

Dear Leo,

Thank you for submitting your implementation. Could you please note the meaning of the algorithm's output in general? What does is produce and in what structure?

Thanks in advance.

Comment only
13 Jul 2012 Siddharth

I tried to compile it and these are the errors I got. Could you please help me out?

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\yvals.h(576) : error C2371: 'char16_t' : redefinition; different basic types
c:\program files\matlab\r2010a\extern\include\matrix.h(330) : see declaration of 'char16_t'
HoG.cpp(10) : warning C4305: 'initializing' : truncation from 'double' to 'const float'
HoG.cpp(21) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
HoG.cpp(22) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
HoG.cpp(36) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(37) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(39) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(41) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(42) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(44) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(46) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(47) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(52) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(53) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(54) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(58) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(59) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(60) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(63) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(64) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(65) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(70) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(71) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(72) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(76) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(77) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(78) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(81) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(82) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(83) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(113) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(114) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(116) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(140) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(141) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(144) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(145) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(146) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(147) : warning C4244: '+=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(153) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(154) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(155) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(165) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(166) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(167) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(168) : warning C4244: '+=' : conversion from 'double' to 'float', possible loss of data
HoG.cpp(174) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(175) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(176) : warning C4018: '<' : signed/unsigned mismatch
HoG.cpp(199) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
HoG.cpp(200) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
HoG.cpp(224) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
HoG.cpp(225) : warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data

C:\PROGRA~1\MATLAB\R2010A\BIN\MEX.PL: Error: Compile of 'HoG.cpp' failed.

??? Error using ==> mex at 222
Unable to complete successfully.

Comment only
08 Jun 2012 Stathis Fotiadis

in mac ox it crashes if you not cast the image as double. i am not sure if this solves the crashing problems.

Comment only
21 Feb 2012 Nicholas

Sorry double posted, this is my first please excuse. Anyway 5 stars for this, code is good and also because HoG itself is amazing. No trouble compiling on Win 7 x64 with VS C++ 2010 Compiler

Comment only
21 Feb 2012 Nicholas  
04 Feb 2012 Leo

Leo (view profile)

Hi Vidit,

I am not very well acquainted with lcc but if I am not mistaken it does not support C++. You need to use a C++ compiler to compile the code.

Leo

Comment only
04 Feb 2012 Vidit Aatrey

Hi Leo,

I am running your code on Matlab 7.8. When compiling the file, I get this error:
lcc preprocessor error: HoG.cpp:4 Could not find include file <vector>
Error HoG.cpp: 5 syntax error; found `namespace' expecting `;'
Error HoG.cpp: 5 syntax error; found `std' expecting `;'
Error HoG.cpp: 30 undeclared identifier `vector'
Error HoG.cpp: 30 illegal expression
Error HoG.cpp: 30 illegal expression
Error HoG.cpp: 30 illegal expression
Error HoG.cpp: 30 illegal expression
Error HoG.cpp: 30 found `int' expected a function
Error HoG.cpp: 30 illegal expression
Error HoG.cpp: 30 operands of > have illegal types `int' and `void'
Error HoG.cpp: 31 illegal expression
Error HoG.cpp: 31 illegal expression
Error HoG.cpp: 31 illegal expression
Error HoG.cpp: 31 illegal expression
Error HoG.cpp: 31 found `int' expected a function
Error HoG.cpp: 31 illegal expression
Error HoG.cpp: 31 operands of > have illegal types `int' and `void'
Error HoG.cpp: 35 syntax error; found `unsigned' expecting `;'
Error HoG.cpp: 35 syntax error; found `unsigned' expecting `;'
Error HoG.cpp: 35 too many errors

C:\PROGRA~1\MATLAB\R2009A\BIN\MEX.PL: Error: Compile of 'HoG.cpp' failed.
Please help.

Vidit

Comment only
03 Feb 2012 Leo

Leo (view profile)

Lino Hi,

I have tried to contact you via email but you haven't replied. I cannot reproduce this error so it is difficult to say what is going on. If anyone has the same problem, please contact me.

Leo

Comment only
23 Jan 2012 Lino

Lino (view profile)

Hi Leo
I'm trying to use this code in a Linux enviroment and Matlab crashes when I use it. The error given is the next one:

MATLAB crash file:/home/lino/matlab_crash_dump.2121
------------------------------------------------------------------------
Segmentation violation detected at Mon Jan 23 11:04:45 2012
------------------------------------------------------------------------

Configuration:
MATLAB Version: 7.8.0.347 (R2009a)
MATLAB License: 161051
Operating System: Linux 3.1.1-1-ARCH #1 SMP PREEMPT Fri Nov 11 22:28:29 CET 2011 x86_64
GNU C Library: 2.14.1 stable
Window System: The X.Org Foundation (11102000), display :0.0
Current Visual: 0x21 (class 4, depth 24)
Processor ID: x86 Family 6 Model 10 Stepping 7, GenuineIntel
Virtual Machine: Java 1.6.0_04-b12 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
Default Encoding: ISO-8859-1

Fault Count: 1

Register State:
rax = 00000000000000bf rbx = 0000000080000000
rcx = 00000003fffffff8 rdx = 0000000000000000
rbp = 00007f770ad419e0 rsi = 0000000000000001
rdi = 00007f7ae94158e8 rsp = 00007f770ad41760
r8 = 000000003fe00000 r9 = 0000000000000000
r10 = 000000003fe00000 r11 = 0000000000000000
r12 = 0000000000000240 r13 = 0000000080000001
r14 = 0000000000000019 r15 = 0000000000000009
rip = 00007f76e404591c flg = 0000000000010a92

Stack Trace:
[0] HoG.mexa64:0x00007f76e404591c(0x7f770ad424e0, 0x1a947e10, 0x19f00000150, 0x7f770ad41ab0)
[1] HoG.mexa64:mexFunction~(0x100000001, 0x7f770ad425a8, 0x127f00000001, 0x7f770ad425a8) + 485 bytes
[2] libmex.so:mexRunMexFile(0x0232c22e "HoG", 0x7f770ad425a0, 0x10ad41ac0, 0x7f770ad424e0) + 90 bytes
[3] libmex.so:Mfh_mex::runMexFileWithSignalProtection(int, mxArray_tag**, int, mxArray_tag**)(0x7f770ad41c80, 0x7f770ad42080, 0x7f770ad424e0, 0x1e9629740) + 137 bytes
[4] libmex.so:Mfh_mex::dispatch_file(int, mxArray_tag**, int, mxArray_tag**)(0x7f770ad425a0, 0x10ad42190, 0x036de6e0, 0x7f770ad43810) + 247 bytes
[5] libmwm_dispatcher.so:Mfh_file::dispatch_fh(int, mxArray_tag**, int, mxArray_tag**)(0x10ad421f0, 0x7f77ffffffff, 0x02cf2d90, 0x7f770ad421f0) + 282 bytes
[6] libmwm_interpreter.so:ResolverFunctionDesc::CallFunction(int, mxArray_tag**, int, mxArray_tag**)(0x100005ecd, 0x7f770ad42400, 0x7f770ad43080, 0x026c9220) + 871 bytes
[7] libmwm_interpreter.so:Resolver::CallMFunction(int, int, _m_operand*, m_operand_storage*, int, _m_operand*, m_operand_storage*, int*)(0x7f76e91f1330, 0, 0x7f770ad43250, 0x2e8ba2e8ba2e8ba3) + 1637 bytes
[8] libmwm_interpreter.so:inResolveMFunctionCall(_m_function_desc*, int, int, _m_operand*, m_operand_storage*, int, _m_operand*, m_operand_storage*, int*, inMarshalType*, int, mpsTypeSequenceNlhs const*, mxArray_tag* (*)(int))(0x7f76e91f1330, 0, 0x7f770ad43250, 0x7f770ad433f8) + 501 bytes
[9] libmwm_interpreter.so:accelImpl::MFunctionCall(_accelOp**)(0x7f770ad431e4, 0x7f76e962c298, 0x1e8a33310, 0x7f76e9623b30) + 239 bytes
[10] libmwm_interpreter.so:accelImpl::Exec()(0x7f770ad433f8, 0x7f770ad433f0, 0x7f76e96d29d0, 0x7f76e9629290) + 273 bytes
[11] libmwm_interpreter.so:accelCode::Call(inMarshalType*, int*) const(0x7f770ad433f8, 0x7f770ad433f0, 0x7f770ad433a0, 0x7f770ad433ff) + 91 bytes
[12] libmwm_interpreter.so:inJit::ExecuteHotSegment(_inJitAccelInfo*, opcodes*, int*, long*)(0x7f770ad43470, 0x7f770ad434bc, 0xffffffff0000006f, 0xffffffff00000000) + 1793 bytes
[13] libmwm_interpreter.so:inExecuteMFunctionOrScript(Mfh_mp*, bool)(0, 0x7f770ad43750, 0, 0) + 1104 bytes
[14] libmwm_interpreter.so:inRunMfile(int, mxArray_tag**, int, mxArray_tag**, Mfh_mp*, inWorkSpace_tag*)(0, 32, 0x7f76e95f0390, 0x7f770ad44830) + 1411 bytes
[15] libmwm_dispatcher.so:Mfh_file::dispatch_fh(int, mxArray_tag**, int, mxArray_tag**)(0x0ad438b0, 0, 0x7f770ad445d0, 0x7f770ad44420) + 282 bytes
[16] libmwm_interpreter.so:inEvalPcodeHeaderToWord(_memory_context*, int, mxArray_tag**, _pcodeheader*, Mfh_mp*, unsigned int)(0x7f770ad438d0, 0x7f770ad43aa0, 0x7f770ad44620, 0) + 170 bytes
[17] libmwm_interpreter.so:in_local_call_script_function(_memory_context*, _pcodeheader*, int, mxArray_tag**, unsigned int, bool)(0x01c08700, 0x01c08790, 0x7f770ad44528, 0x7f770ad44534) + 103 bytes
[18] libmwm_interpreter.so:inEvalStringWithIsVarFcn(_memory_context*, char const*, EvalType, int, mxArray_tag**, inDebugCheck, _pcodeheader*, int*, bool (*)(void*, char const*), void*, bool, bool)(0, 0, 0x7f7718dbefc0, 0) + 2610 bytes
[19] libmwm_interpreter.so:inEvalCmdWithLocalReturn(char const*, int*, bool, bool, bool (*)(void*, char const*))(0x7f770ad44630, 0x7f76e96cd6b0 "hogs_8=HoG(I);\n", 0x7f770ad447f0, 0) + 149 bytes
[20] libmwbridge.so:evalCommandWithLongjmpSafety(char const*)(0x7f770ad44800, 0x7f770ad44850, 0x7f770ad44860, 0x7f770ad44870) + 94 bytes
[21] libmwbridge.so:mnParser(0x01b324c0, 0x02d642f0, 0x197a3101, 0x0a53fba0) + 355 bytes
[22] libmwmcr.so:mcrInstance::mnParser_on_interpreter_thread()(0x00c00000, 0xfffffffffffffc00, 0xffffffffffffffff, 0x80101020000ffff) + 41 bytes
[23] libmwmcr.so:boost::function0<void>::operator()() const(0x7f770ad44a60, 0x7f770ad449e0, 0x7f770ad449a0, 0x7f77197b7e71) + 123 bytes
[24] libmwmcr.so:mcr::runtime::InterpreterThread::Impl::NoResultInvocationRequest::run()(0x7f770ad449e0, 0x02cf3c10, 0x02f25630, 0x02cf3c10) + 21 bytes
[25] libmwmcr.so:mcr::runtime::InterpreterThread::Impl::invocation_request_handler(long)(0x7f770ad449e0, 0x7f770ad44aa0, 0x7f770ad44800, 0x3000000020) + 33 bytes
[26] libmwuix.so:uix_DispatchOrProcess(_XEvent*, _XtAppStruct*, int, bool)(0x01b37a80, 0x7f771a988b5c, 0x7f770ad44bf0, 0x1007f7700000001) + 361 bytes
[27] libmwuix.so:ws_ProcessPendingEventsHelper(int, int, bool)(9, 0x01b31060, 0x01b367a0, 0x01b36700) + 489 bytes
[28] libmwmcr.so:mcr::runtime::InterpreterThread::Impl::process_events(boost::shared_ptr<mcr::runtime::InterpreterThread::Impl> const&)(0x7f771979d000, 0x7f770ad44cf0, 0x7f76e079d5a0, 0) + 225 bytes
[29] libmwmcr.so:mcr::runtime::InterpreterThread::Impl::run(boost::shared_ptr<mcr::runtime::InterpreterThread::Impl> const&, mcr::runtime::InterpreterThread::Impl::init_context*)(0x01b36700, 0x01b367a0, 0x01b321e0, 0x7f770ad44de0) + 237 bytes
[30] libmwmcr.so:run_init_and_handle_events(void*)(0, 0x00801000, 0x7f770ad44e10, 0x00402670) + 60 bytes
[31] MATLAB:boost::function0<void>::operator()() const(0x7fff61464428, 0x200000000, 0, 0x01b321e0) + 412 bytes
[32] MATLAB:mcrMain(int, char const**)(0x7f770ad44f20, 0x7f770ad45700, 0, 0x7fff61464270) + 243 bytes
[33] libmwmcr.so:runMcrMain(void*)(0, 0x7f770ad45700, 0, 0) + 28 bytes

Comment only
16 Jan 2012 Leo

Leo (view profile)

Hi Nour,

Perhaps the function is not in Matlab's search path? Another possibility is that you forgot to compile it before running.

Otherwise can't think of what the problem might be.

Comment only
15 Jan 2012 Nour CHARARA

Hi Leo,
thanks for this submission,
but help needed, I can't run the mex file
I have this message error
>> Image = imread ('test.jpg');
>> hogs = HoG(Image);
??? Undefined function or method 'HoG' for input arguments of type 'uint8'.

Can you help me? thanks a lot

Comment only
02 Jan 2012 Leo

Leo (view profile)

Hi syki,

The code has been developed and tested on 64-bit Ubuntu with Matlab 7.9.0 (R2009b).

Comment only
01 Jan 2012 syki.mail

hi leo
I use a HOG function in matlab? it is recognized by Matlab 7.9 ?

Comment only
31 Dec 2011 rondesu

Hi Leo, sorry bout the multiple ratings. The code now works perfectly. Thanks a lot.

Comment only
31 Dec 2011 rondesu  
27 Dec 2011 Leo

Leo (view profile)

Hi Ronald,

I reformatted the code to use vectors instead of static arrays. Should be standard C,C++ compliant.

Comment only
20 Dec 2011 Leo

Leo (view profile)

Hi Ronald, disregard the previous post, it is probably due to the fact that in standard C/C++ arrays h, block (lines 28 and 29) have to be dynamically allocated (or declared using vectors). I don't have time now to correct this, but if you can't do it , I'll try to do it by tomorrow.

Comment only
20 Dec 2011 rondesu

Hi Leo, thanks for the reply. I did the changes you mentioned in your post but the problem remain unsolved. I'm wondering could it be due to the platform I'm using? For I'm using Windows.

Comment only
18 Dec 2011 Leo

Leo (view profile)

Hi Ronald, based on those errors maybe the following will help :

add a const in front of each line from 8 to 21, so for example :

int nb_bins = (int) params[0];

should become

const int nb_bins = (int) params[0];

then add a line :

unsigned int i,j,k,cli,x,y;

at line 22.

Finally remove all declarations from the for loops. For example line 39 :

for(unsigned int y=0; y<img_height; y++) {

should become

for(y=0; y<img_height; y++) {

Not sure this helps, hope it does.

Leo

Comment only
18 Dec 2011 rondesu

Error HoG.cpp: 28 integer expression must be constant
Error HoG.cpp: 28 integer expression must be constant
Error HoG.cpp: 28 integer expression must be constant
Error HoG.cpp: 29 integer expression must be constant
Error HoG.cpp: 29 integer expression must be constant
Error HoG.cpp: 29 integer expression must be constant
Error HoG.cpp: 31 syntax error; found `int' expecting `;'
Error HoG.cpp: 31 syntax error; found `int' expecting `;'
Error HoG.cpp: 31 syntax error; found `int' expecting `)'
Error HoG.cpp: 31 skipping `int'
Error HoG.cpp: 31 undeclared identifier `x'
Warning HoG.cpp: 31 Statement has no effect
Warning HoG.cpp: 31 unreachable code
Error HoG.cpp: 31 syntax error; found `)' expecting `;'
Error HoG.cpp: 31 illegal statement termination
Error HoG.cpp: 31 skipping `)'
Error HoG.cpp: 32 syntax error; found `int' expecting `;'
Error HoG.cpp: 32 syntax error; found `int' expecting `;'
Error HoG.cpp: 32 syntax error; found `int' expecting `)'
Error HoG.cpp: 32 skipping `int'
Error HoG.cpp: 32 undeclared identifier `y'
Warning HoG.cpp: 32 Statement has no effect
Warning HoG.cpp: 32 unreachable code
Error HoG.cpp: 32 syntax error; found `)' expecting `;'
Error HoG.cpp: 32 too many errors

C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: Compile of 'HoG.cpp' failed.

Error using mex (line 206)
Unable to complete successfully.

Comment only
18 Dec 2011 Leo

Leo (view profile)

Hi Ronald, can you provide me with the compilation errors you get?

Comment only
18 Dec 2011 rondesu

Hi Leo, help needed. I can't manage to get this code to work. I can't compile the HoG.cpp file provided. Thanks.

Comment only
Updates
22 Nov 2011 1.1

typo in description

26 Dec 2011 1.3

code should now be standard C/C++ compliant

15 Aug 2012 1.4

Function returns an error if input is not of type double

Contact us