Operations.h 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261
  1. /**
  2. * @file Operation.h
  3. * @brief abstract class for any kind of feature extraction from 3d images
  4. * @author Björn Fröhlich, Sven Sickert
  5. * @date 24.04.2012
  6. */
  7. #include "core/image/MultiChannelImageT.h"
  8. #include "core/image/MultiChannelImage3DT.h"
  9. #define BOUND(x,min,max) (((x)<(min))?(min):((x)>(max)?(max):(x)))
  10. namespace OBJREC {
  11. class Operation;
  12. /**
  13. * @brief methods for value access
  14. **/
  15. enum ValueTypes
  16. {
  17. RAWFEAT,
  18. CONTEXT
  19. };
  20. /**
  21. * @brief feature extraction methods
  22. **/
  23. enum OperationTypes {
  24. MINUS,
  25. MINUSABS,
  26. ADDITION,
  27. ONLY1,
  28. INTEGRAL,
  29. INTEGRALCENT,
  30. BIINTEGRALCENT,
  31. HAARHORIZ,
  32. HAARVERT,
  33. HAARSTACK,
  34. HAARDIAGXY,
  35. HAARDIAGXZ,
  36. HAARDIAGYZ,
  37. HAAR3HORIZ,
  38. HAAR3VERT,
  39. HAAR3STACK,
  40. RELATIVEXPOSITION,
  41. RELATIVEYPOSITION,
  42. RELATIVEZPOSITION,
  43. GLOBALFEATS,
  44. EQUALITY,
  45. NBOPERATIONS
  46. };
  47. /**
  48. * @brief node class for context tree
  49. **/
  50. class TreeNode
  51. {
  52. public:
  53. /** left child node */
  54. int left;
  55. /** right child node */
  56. int right;
  57. /** position of feat for decision */
  58. Operation *feat;
  59. /** decision stamp */
  60. double decision;
  61. /** is the node a leaf or not */
  62. bool isleaf;
  63. /** distribution in current node */
  64. std::vector<double> dist;
  65. /** depth of the node in the tree */
  66. int depth;
  67. /** how many pixels are in this node */
  68. int featcounter;
  69. /** unique number */
  70. int nodeNumber;
  71. /** simple constructor */
  72. TreeNode() : left ( -1 ), right ( -1 ), feat ( NULL ), decision ( -1.0 ), isleaf ( false ) {}
  73. /** standard constructor */
  74. TreeNode ( int _left, int _right, Operation *_feat, double _decision ) : left ( _left ), right ( _right ), feat ( _feat ), decision ( _decision ), isleaf ( false ) {}
  75. /**
  76. * @brief initialize node
  77. * @param _depth current depth in tree
  78. * @param _numClasses amount of classes (initialize distribution)
  79. * @param _nodeNumber unique node number
  80. */
  81. void init( int _depth, int _numClasses, int _nodeNumber)
  82. {
  83. depth = _depth;
  84. featcounter = 0;
  85. dist = std::vector<double> (_numClasses, 0.0);
  86. nodeNumber = _nodeNumber;
  87. }
  88. };
  89. /**
  90. * @brief holds all necessary information for feature extraction of 3d images
  91. **/
  92. struct Features {
  93. /** simple features like RGB values */
  94. NICE::MultiChannelImage3DT<double> *feats;
  95. /** node index for each pixel (width,height,depth) in each tree (channel) */
  96. NICE::MultiChannelImage3DT<unsigned short int> *nIndices;
  97. /** current tree index */
  98. int cTree;
  99. /** current tree (all nodes) */
  100. std::vector<TreeNode> *tree;
  101. /** probabilities for each region */
  102. std::vector<std::vector<double> > *rProbs;
  103. };
  104. /**
  105. * @brief abstract operation class
  106. **/
  107. class Operation
  108. {
  109. protected:
  110. /** two different points (e.g. for an rectangle or two positions), channels and size */
  111. int x1, y1, z1, x2, y2, z2, channel1, channel2, maxtypes;
  112. /** type of feature */
  113. int featType;
  114. bool init;
  115. bool context;
  116. public:
  117. /** simple constructor */
  118. Operation();
  119. /**
  120. * @brief set all parameters
  121. * @param _x1 position 1
  122. * @param _y1 position 1
  123. * @param _z1 position 1
  124. * @param _x2 position 2
  125. * @param _y2 position 2
  126. * @param _z2 position 2
  127. * @param _channel1 channel 1
  128. * @param _channel2 channel 2
  129. * @param _ftype feature type
  130. * @return void nothing
  131. **/
  132. virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int _featType );
  133. /**
  134. * @brief set whether it is a context feature or not
  135. * @param _context context boolean
  136. * @return void nothing
  137. **/
  138. void setContext ( bool _context );
  139. /**
  140. * @brief return context information (set by setContext(bool)
  141. *
  142. * @return bool whether context is used or not
  143. **/
  144. bool getContext();
  145. /**
  146. * @brief set type of feature
  147. * @param _featType type of feature
  148. * @return void nothing
  149. **/
  150. void setFeatType ( int _featType );
  151. /**
  152. * @brief return context information (set by setContext(bool)
  153. *
  154. * @return int get feature type
  155. **/
  156. int getFeatType();
  157. /**
  158. * @brief abstract interface for feature computation
  159. * @param feats features
  160. * @param x current x position
  161. * @param y current y position
  162. * @param z current z position
  163. * @return double distance
  164. **/
  165. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z ) = 0;
  166. /**
  167. * @brief virtual clone operation instead of copy constructor (copy constructor does not work)
  168. **/
  169. virtual Operation* clone() = 0;
  170. /**
  171. * @brief print some infos about operation extraction type
  172. * @return string feature type
  173. **/
  174. virtual std::string writeInfos();
  175. /**
  176. * @brief exctract current image boarders
  177. * @param feats image information
  178. * @param xsize width
  179. * @param ysize height
  180. * @param zsize depth
  181. * @return void
  182. **/
  183. inline void getXYZ ( const Features &feats, int &xsize, int &ysize, int &zsize );
  184. /**
  185. * @brief return operation type (for store and restore)
  186. * @return OperationTypes
  187. **/
  188. virtual OperationTypes getOps() = 0;
  189. /**
  190. * @brief store all information for current operation in stream
  191. * @param os out stream
  192. * @return void
  193. **/
  194. virtual void store ( std::ostream & os );
  195. /**
  196. * @brief restore all information for current operation from stream
  197. * @param is in stream
  198. * @return void
  199. **/
  200. virtual void restore ( std::istream & is );
  201. };
  202. /**
  203. * @brief simple equality check ?(A==B)
  204. **/
  205. class RegionFeat: public Operation
  206. {
  207. public:
  208. /**
  209. * @brief interface for feature computation
  210. * @param feats features
  211. * @param x current x position
  212. * @param y current y position
  213. * @param z current z position
  214. * @return double distance
  215. **/
  216. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  217. /**
  218. * @brief clone operation instead of copy constructor (copy constructor does not work)
  219. **/
  220. virtual Operation* clone()
  221. {
  222. return new RegionFeat();
  223. }
  224. /**
  225. * @brief print some infos about operation extraction type
  226. * @return string feature type
  227. **/
  228. virtual std::string writeInfos()
  229. {
  230. return "RegionFeat" + Operation::writeInfos();
  231. }
  232. /**
  233. * @brief return operation type (for store and restore)
  234. * @return OperationTypes
  235. **/
  236. virtual OperationTypes getOps()
  237. {
  238. return EQUALITY;
  239. }
  240. };
  241. /**
  242. * @brief simple difference operation A-B
  243. **/
  244. class Minus: public Operation
  245. {
  246. public:
  247. /**
  248. * @brief interface for feature computation
  249. * @param feats features
  250. * @param x current x position
  251. * @param y current y position
  252. * @param z current z position
  253. * @return double distance
  254. **/
  255. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  256. /**
  257. * @brief clone operation instead of copy constructor (copy constructor does not work)
  258. **/
  259. virtual Operation* clone()
  260. {
  261. return new Minus();
  262. }
  263. /**
  264. * @brief print some infos about operation extraction type
  265. * @return string feature type
  266. **/
  267. virtual std::string writeInfos()
  268. {
  269. std::string out = "Minus";
  270. if (init)
  271. {
  272. if ( featType == 4 )
  273. out += "context";
  274. else
  275. out += "raw";
  276. }
  277. return out + Operation::writeInfos();
  278. }
  279. /**
  280. * @brief return operation type (for store and restore)
  281. * @return OperationTypes
  282. **/
  283. virtual OperationTypes getOps()
  284. {
  285. return MINUS;
  286. }
  287. };
  288. /**
  289. * @brief simple absolute difference operation |A-B|
  290. **/
  291. class MinusAbs: public Operation
  292. {
  293. public:
  294. /**
  295. * @brief interface for feature computation
  296. * @param feats features
  297. * @param x current x position
  298. * @param y current y position
  299. * @param z current z position
  300. * @return double distance
  301. **/
  302. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  303. /**
  304. * @brief clone operation instead of copy constructor (copy constructor does not work)
  305. **/
  306. virtual Operation* clone()
  307. {
  308. return new MinusAbs();
  309. }
  310. /**
  311. * @brief print some infos about operation extraction type
  312. * @return string feature type
  313. **/
  314. virtual std::string writeInfos()
  315. {
  316. std::string out = "MinusAbs";
  317. if (init)
  318. {
  319. if ( featType == 4 )
  320. out += "context";
  321. else
  322. out += "raw";
  323. }
  324. return out;
  325. }
  326. /**
  327. * @brief return operation type (for store and restore)
  328. * @return OperationTypes
  329. **/
  330. virtual OperationTypes getOps()
  331. {
  332. return MINUSABS;
  333. }
  334. };
  335. /**
  336. * @brief simple addition operation A+B
  337. **/
  338. class Addition: public Operation
  339. {
  340. public:
  341. /**
  342. * @brief interface for feature computation
  343. * @param feats features
  344. * @param x current x position
  345. * @param y current y position
  346. * @param z current z position
  347. * @return double distance
  348. **/
  349. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  350. /**
  351. * @brief clone operation instead of copy constructor (copy constructor does not work)
  352. **/
  353. virtual Operation* clone()
  354. {
  355. return new Addition();
  356. }
  357. /**
  358. * @brief print some infos about operation extraction type
  359. * @return string feature type
  360. **/
  361. virtual std::string writeInfos()
  362. {
  363. std::string out = "Addition";
  364. if (init)
  365. {
  366. if ( featType == 4 )
  367. out += "context";
  368. else
  369. out += "raw";
  370. }
  371. return out + Operation::writeInfos();
  372. }
  373. /**
  374. * @brief return operation type (for store and restore)
  375. * @return OperationTypes
  376. **/
  377. virtual OperationTypes getOps()
  378. {
  379. return ADDITION;
  380. }
  381. };
  382. /**
  383. * @brief simple single element access operation
  384. **/
  385. class Only1: public Operation
  386. {
  387. public:
  388. /**
  389. * @brief interface for feature computation
  390. * @param feats features
  391. * @param x current x position
  392. * @param y current y position
  393. * @param z current z position
  394. * @return double distance
  395. **/
  396. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  397. /**
  398. * @brief clone operation instead of copy constructor (copy constructor does not work)
  399. **/
  400. virtual Operation* clone()
  401. {
  402. return new Only1();
  403. }
  404. /**
  405. * @brief print some infos about operation extraction type
  406. * @return string feature type
  407. **/
  408. virtual std::string writeInfos()
  409. {
  410. std::string out = "Only1";
  411. if (init)
  412. {
  413. if ( featType == 4 )
  414. out += "context";
  415. else
  416. out += "raw";
  417. }
  418. return out + Operation::writeInfos();
  419. }
  420. /**
  421. * @brief return operation type (for store and restore)
  422. * @return OperationTypes
  423. **/
  424. virtual OperationTypes getOps()
  425. {
  426. return ONLY1;
  427. }
  428. };
  429. /**
  430. * @brief get current relative x position
  431. **/
  432. class RelativeXPosition: public Operation
  433. {
  434. public:
  435. /**
  436. * @brief interface for feature computation
  437. * @param feats features
  438. * @param x current x position
  439. * @param y current y position
  440. * @param z current z position
  441. * @return double distance
  442. **/
  443. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  444. /**
  445. * @brief clone operation instead of copy constructor (copy constructor does not work)
  446. **/
  447. virtual Operation* clone()
  448. {
  449. return new RelativeXPosition();
  450. }
  451. /**
  452. * @brief print some infos about operation extraction type
  453. * @return string feature type
  454. **/
  455. virtual std::string writeInfos()
  456. {
  457. return "RelativeXPosition" + Operation::writeInfos();
  458. }
  459. /**
  460. * @brief return operation type (for store and restore)
  461. * @return OperationTypes
  462. **/
  463. virtual OperationTypes getOps()
  464. {
  465. return RELATIVEXPOSITION;
  466. }
  467. };
  468. /**
  469. * @brief get current relative y position
  470. **/
  471. class RelativeYPosition: public Operation
  472. {
  473. public:
  474. /**
  475. * @brief interface for feature computation
  476. * @param feats features
  477. * @param x current x position
  478. * @param y current y position
  479. * @param z current z position
  480. * @return double distance
  481. **/
  482. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  483. /**
  484. * @brief clone operation instead of copy constructor (copy constructor does not work)
  485. **/
  486. virtual Operation* clone()
  487. {
  488. return new RelativeYPosition();
  489. }
  490. /**
  491. * @brief print some infos about operation extraction type
  492. * @return string feature type
  493. **/
  494. virtual std::string writeInfos()
  495. {
  496. return "RelativeYPosition" + Operation::writeInfos();
  497. }
  498. /**
  499. * @brief return operation type (for store and restore)
  500. * @return OperationTypes
  501. **/
  502. virtual OperationTypes getOps()
  503. {
  504. return RELATIVEYPOSITION;
  505. }
  506. };
  507. /**
  508. * @brief get current relative z position
  509. **/
  510. class RelativeZPosition: public Operation
  511. {
  512. public:
  513. /**
  514. * @brief interface for feature computation
  515. * @param feats features
  516. * @param x current x position
  517. * @param y current y position
  518. * @param z current z position
  519. * @return double distance
  520. **/
  521. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  522. /**
  523. * @brief clone operation instead of copy constructor (copy constructor does not work)
  524. **/
  525. virtual Operation* clone()
  526. {
  527. return new RelativeZPosition();
  528. }
  529. /**
  530. * @brief print some infos about operation extraction type
  531. * @return string feature type
  532. **/
  533. virtual std::string writeInfos()
  534. {
  535. return "RelativeZPosition" + Operation::writeInfos();
  536. }
  537. /**
  538. * @brief return operation type (for store and restore)
  539. * @return OperationTypes
  540. **/
  541. virtual OperationTypes getOps()
  542. {
  543. return RELATIVEZPOSITION;
  544. }
  545. };
  546. /**
  547. * @brief uses mean in a window given by (x1,y1,z1) (x2,y2,z2)
  548. **/
  549. class IntegralOps: public Operation
  550. {
  551. public:
  552. /**
  553. * @brief set all parameters
  554. * @param _x1 position 1
  555. * @param _y1 position 1
  556. * @param _z1 position 1
  557. * @param _x2 position 2
  558. * @param _y2 position 2
  559. * @param _z2 position 2
  560. * @param _channel1 channel 1
  561. * @param _channel2 channel 2
  562. * @param _ftype feature type
  563. * @return void nothing
  564. **/
  565. virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int _ftype );
  566. /**
  567. * @brief interface for feature computation
  568. * @param feats features
  569. * @param x current x position
  570. * @param y current y position
  571. * @param z current z position
  572. * @return double distance
  573. **/
  574. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  575. /**
  576. * @brief clone operation instead of copy constructor (copy constructor does not work)
  577. **/
  578. virtual Operation* clone()
  579. {
  580. return new IntegralOps();
  581. }
  582. /**
  583. * @brief print some infos about operation extraction type
  584. * @return string feature type
  585. **/
  586. virtual std::string writeInfos()
  587. {
  588. return "IntegralOps" + Operation::writeInfos();
  589. }
  590. /**
  591. * @brief return operation type (for store and restore)
  592. * @return OperationTypes
  593. **/
  594. virtual OperationTypes getOps()
  595. {
  596. return INTEGRAL;
  597. }
  598. };
  599. /**
  600. * @brief like a global bag of words to model the current appearance of classes in an image without local context
  601. **/
  602. class GlobalFeats: public IntegralOps
  603. {
  604. public:
  605. /**
  606. * @brief interface for feature computation
  607. * @param feats features
  608. * @param x current x position
  609. * @param y current y position
  610. * @param z current z position
  611. * @return double distance
  612. **/
  613. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  614. /**
  615. * @brief clone operation instead of copy constructor (copy constructor does not work)
  616. **/
  617. virtual Operation* clone()
  618. {
  619. return new GlobalFeats();
  620. }
  621. /**
  622. * @brief print some infos about operation extraction type
  623. * @return string feature type
  624. **/
  625. virtual std::string writeInfos()
  626. {
  627. return "GlobalFeats" + Operation::writeInfos();
  628. }
  629. /**
  630. * @brief return operation type (for store and restore)
  631. * @return OperationTypes
  632. **/
  633. virtual OperationTypes getOps()
  634. {
  635. return GLOBALFEATS;
  636. }
  637. };
  638. /**
  639. * @brief uses mean of Integral image given by x1, y1, z1 with current pixel as center
  640. **/
  641. class IntegralCenteredOps: public IntegralOps
  642. {
  643. public:
  644. /**
  645. * @brief set all parameters
  646. * @param _x1 position 1
  647. * @param _y1 position 1
  648. * @param _z1 position 1
  649. * @param _x2 position 2
  650. * @param _y2 position 2
  651. * @param _z2 position 2
  652. * @param _channel1 channel 1
  653. * @param _channel2 channel 2
  654. * @param _ftype feature type
  655. * @return void nothing
  656. **/
  657. virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int _ftype );
  658. /**
  659. * @brief interface for feature computation
  660. * @param feats features
  661. * @param x current x position
  662. * @param y current y position
  663. * @param z current z position
  664. * @return double distance
  665. **/
  666. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  667. /**
  668. * @brief clone operation instead of copy constructor (copy constructor does not work)
  669. **/
  670. virtual Operation* clone()
  671. {
  672. return new IntegralCenteredOps();
  673. }
  674. /**
  675. * @brief print some infos about operation extraction type
  676. * @return string feature type
  677. **/
  678. virtual std::string writeInfos()
  679. {
  680. return "IntegralCenteredOps" + Operation::writeInfos();
  681. }
  682. /**
  683. * @brief return operation type (for store and restore)
  684. * @return OperationTypes
  685. **/
  686. virtual OperationTypes getOps()
  687. {
  688. return INTEGRALCENT;
  689. }
  690. };
  691. /**
  692. * @brief uses different of mean of Integral image given by two windows, where (x1,y1,z1) is the width, height & depth of window1 and (x2,y2,z2) of window 2
  693. **/
  694. class BiIntegralCenteredOps: public IntegralCenteredOps
  695. {
  696. public:
  697. /**
  698. * @brief set all parameters
  699. * @param _x1 position 1
  700. * @param _y1 position 1
  701. * @param _z1 position 1
  702. * @param _x2 position 2
  703. * @param _y2 position 2
  704. * @param _z2 position 2
  705. * @param _channel1 channel 1
  706. * @param _channel2 channel 2
  707. * @param _ftype feature type
  708. * @return void nothing
  709. **/
  710. virtual void set ( int _x1, int _y1, int _z1, int _x2, int _y2, int _z2, int _channel1, int _channel2, int ftype );
  711. /**
  712. * @brief interface for feature computation
  713. * @param feats features
  714. * @param x current x position
  715. * @param y current y position
  716. * @param z current z position
  717. * @return double distance
  718. **/
  719. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  720. /**
  721. * @brief clone operation instead of copy constructor (copy constructor does not work)
  722. **/
  723. virtual Operation* clone()
  724. {
  725. return new BiIntegralCenteredOps();
  726. }
  727. /**
  728. * @brief print some infos about operation extraction type
  729. * @return string feature type
  730. **/
  731. virtual std::string writeInfos()
  732. {
  733. return "BiIntegralCenteredOps" + Operation::writeInfos();
  734. }
  735. /**
  736. * @brief return operation type (for store and restore)
  737. * @return OperationTypes
  738. **/
  739. virtual OperationTypes getOps()
  740. {
  741. return BIINTEGRALCENT;
  742. }
  743. };
  744. /**
  745. * @brief horizontal Haar features
  746. * ++
  747. * --
  748. **/
  749. class HaarHorizontal: public IntegralCenteredOps
  750. {
  751. public:
  752. /**
  753. * @brief interface for feature computation
  754. * @param feats features
  755. * @param x current x position
  756. * @param y current y position
  757. * @param z current z position
  758. * @return double distance
  759. **/
  760. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  761. /**
  762. * @brief clone operation instead of copy constructor (copy constructor does not work)
  763. **/
  764. virtual Operation* clone()
  765. {
  766. return new HaarHorizontal();
  767. }
  768. /**
  769. * @brief print some infos about operation extraction type
  770. * @return string feature type
  771. **/
  772. virtual std::string writeInfos()
  773. {
  774. return "HaarHorizontal" + Operation::writeInfos();
  775. }
  776. /**
  777. * @brief return operation type (for store and restore)
  778. * @return OperationTypes
  779. **/
  780. virtual OperationTypes getOps()
  781. {
  782. return HAARHORIZ;
  783. }
  784. };
  785. /**
  786. * @brief vertical Haar features
  787. * +-
  788. * +-
  789. **/
  790. class HaarVertical: public IntegralCenteredOps
  791. {
  792. public:
  793. /**
  794. * @brief interface for feature computation
  795. * @param feats features
  796. * @param x current x position
  797. * @param y current y position
  798. * @param z current z position
  799. * @return double distance
  800. **/
  801. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  802. /**
  803. * @brief clone operation instead of copy constructor (copy constructor does not work)
  804. **/
  805. virtual Operation* clone()
  806. {
  807. return new HaarVertical();
  808. }
  809. /**
  810. * @brief print some infos about operation extraction type
  811. * @return string feature type
  812. **/
  813. virtual std::string writeInfos()
  814. {
  815. return "HaarVertical" + Operation::writeInfos();
  816. }
  817. /**
  818. * @brief return operation type (for store and restore)
  819. * @return OperationTypes
  820. **/
  821. virtual OperationTypes getOps()
  822. {
  823. return HAARVERT;
  824. }
  825. };
  826. /**
  827. * @brief stacked (depth) Haar features
  828. * +-
  829. * +-
  830. **/
  831. class HaarStacked: public IntegralCenteredOps
  832. {
  833. public:
  834. /**
  835. * @brief interface for feature computation
  836. * @param feats features
  837. * @param x current x position
  838. * @param y current y position
  839. * @param z current z position
  840. * @return double distance
  841. **/
  842. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  843. /**
  844. * @brief clone operation instead of copy constructor (copy constructor does not work)
  845. **/
  846. virtual Operation* clone()
  847. {
  848. return new HaarStacked();
  849. }
  850. /**
  851. * @brief print some infos about operation extraction type
  852. * @return string feature type
  853. **/
  854. virtual std::string writeInfos()
  855. {
  856. return "HaarStacked" + Operation::writeInfos();
  857. }
  858. /**
  859. * @brief return operation type (for store and restore)
  860. * @return OperationTypes
  861. **/
  862. virtual OperationTypes getOps()
  863. {
  864. return HAARSTACK;
  865. }
  866. };
  867. /**
  868. * @brief x-y diagonal Haar features
  869. * +-
  870. * -+
  871. **/
  872. class HaarDiagXY: public IntegralCenteredOps
  873. {
  874. public:
  875. /**
  876. * @brief interface for feature computation
  877. * @param feats features
  878. * @param x current x position
  879. * @param y current y position
  880. * @param z current z position
  881. * @return double distance
  882. **/
  883. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  884. /**
  885. * @brief clone operation instead of copy constructor (copy constructor does not work)
  886. **/
  887. virtual Operation* clone()
  888. {
  889. return new HaarDiagXY();
  890. }
  891. /**
  892. * @brief print some infos about operation extraction type
  893. * @return string feature type
  894. **/
  895. virtual std::string writeInfos()
  896. {
  897. return "HaarDiagXY" + Operation::writeInfos();
  898. }
  899. /**
  900. * @brief return operation type (for store and restore)
  901. * @return OperationTypes
  902. **/
  903. virtual OperationTypes getOps()
  904. {
  905. return HAARDIAGXY;
  906. }
  907. };
  908. /**
  909. * @brief x-z diagonal Haar features
  910. * +-
  911. * -+
  912. **/
  913. class HaarDiagXZ: public IntegralCenteredOps
  914. {
  915. public:
  916. /**
  917. * @brief interface for feature computation
  918. * @param feats features
  919. * @param x current x position
  920. * @param y current y position
  921. * @param z current z position
  922. * @return double distance
  923. **/
  924. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  925. /**
  926. * @brief clone operation instead of copy constructor (copy constructor does not work)
  927. **/
  928. virtual Operation* clone()
  929. {
  930. return new HaarDiagXZ();
  931. }
  932. /**
  933. * @brief print some infos about operation extraction type
  934. * @return string feature type
  935. **/
  936. virtual std::string writeInfos()
  937. {
  938. return "HaarDiagXZ" + Operation::writeInfos();
  939. }
  940. /**
  941. * @brief return operation type (for store and restore)
  942. * @return OperationTypes
  943. **/
  944. virtual OperationTypes getOps()
  945. {
  946. return HAARDIAGXZ;
  947. }
  948. };
  949. /**
  950. * @brief y-z diagonal Haar features
  951. * +-
  952. * -+
  953. **/
  954. class HaarDiagYZ: public IntegralCenteredOps
  955. {
  956. public:
  957. /**
  958. * @brief interface for feature computation
  959. * @param feats features
  960. * @param x current x position
  961. * @param y current y position
  962. * @param z current z position
  963. * @return double distance
  964. **/
  965. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  966. /**
  967. * @brief clone operation instead of copy constructor (copy constructor does not work)
  968. **/
  969. virtual Operation* clone()
  970. {
  971. return new HaarDiagYZ();
  972. }
  973. /**
  974. * @brief print some infos about operation extraction type
  975. * @return string feature type
  976. **/
  977. virtual std::string writeInfos()
  978. {
  979. return "HaarDiagYZ" + Operation::writeInfos();
  980. }
  981. /**
  982. * @brief return operation type (for store and restore)
  983. * @return OperationTypes
  984. **/
  985. virtual OperationTypes getOps()
  986. {
  987. return HAARDIAGYZ;
  988. }
  989. };
  990. /**
  991. * @brief horizontal Haar features
  992. * +++
  993. * ---
  994. * +++
  995. */
  996. class Haar3Horiz: public BiIntegralCenteredOps
  997. {
  998. public:
  999. /**
  1000. * @brief interface for feature computation
  1001. * @param feats features
  1002. * @param x current x position
  1003. * @param y current y position
  1004. * @param z current z position
  1005. * @return double distance
  1006. **/
  1007. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  1008. /**
  1009. * @brief clone operation instead of copy constructor (copy constructor does not work)
  1010. **/
  1011. virtual Operation* clone()
  1012. {
  1013. return new Haar3Horiz();
  1014. }
  1015. /**
  1016. * @brief print some infos about operation extraction type
  1017. * @return string feature type
  1018. **/
  1019. virtual std::string writeInfos()
  1020. {
  1021. return "Haar3Horiz" + Operation::writeInfos();
  1022. }
  1023. /**
  1024. * @brief return operation type (for store and restore)
  1025. * @return OperationTypes
  1026. **/
  1027. virtual OperationTypes getOps()
  1028. {
  1029. return HAAR3HORIZ;
  1030. }
  1031. };
  1032. /**
  1033. * @brief vertical Haar features
  1034. * +-+
  1035. * +-+
  1036. * +-+
  1037. */
  1038. class Haar3Vert: public BiIntegralCenteredOps
  1039. {
  1040. public:
  1041. /**
  1042. * @brief interface for feature computation
  1043. * @param feats features
  1044. * @param x current x position
  1045. * @param y current y position
  1046. * @param z current z position
  1047. * @return double distance
  1048. **/
  1049. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  1050. /**
  1051. * @brief clone operation instead of copy constructor (copy constructor does not work)
  1052. **/
  1053. virtual Operation* clone()
  1054. {
  1055. return new Haar3Vert();
  1056. }
  1057. /**
  1058. * @brief print some infos about operation extraction type
  1059. * @return string feature type
  1060. **/
  1061. virtual std::string writeInfos()
  1062. {
  1063. return "Haar3Vert" + Operation::writeInfos();
  1064. }
  1065. /**
  1066. * @brief return operation type (for store and restore)
  1067. * @return OperationTypes
  1068. **/
  1069. virtual OperationTypes getOps()
  1070. {
  1071. return HAAR3VERT;
  1072. }
  1073. };
  1074. /**
  1075. * @brief stacked Haar features
  1076. * +-+
  1077. * +-+
  1078. * +-+
  1079. */
  1080. class Haar3Stack: public BiIntegralCenteredOps
  1081. {
  1082. public:
  1083. /**
  1084. * @brief interface for feature computation
  1085. * @param feats features
  1086. * @param x current x position
  1087. * @param y current y position
  1088. * @param z current z position
  1089. * @return double distance
  1090. **/
  1091. virtual double getVal ( const Features &feats, const int &x, const int &y, const int &z );
  1092. /**
  1093. * @brief clone operation instead of copy constructor (copy constructor does not work)
  1094. **/
  1095. virtual Operation* clone()
  1096. {
  1097. return new Haar3Stack();
  1098. }
  1099. /**
  1100. * @brief print some infos about operation extraction type
  1101. * @return string feature type
  1102. **/
  1103. virtual std::string writeInfos()
  1104. {
  1105. return "Haar3Stack" + Operation::writeInfos();
  1106. }
  1107. /**
  1108. * @brief return operation type (for store and restore)
  1109. * @return OperationTypes
  1110. **/
  1111. virtual OperationTypes getOps()
  1112. {
  1113. return HAAR3STACK;
  1114. }
  1115. };
  1116. } //end namespace