Skip to content

Commit

Permalink
defining interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
internaut committed May 15, 2014
1 parent ac07c27 commit 9e44747
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 8 deletions.
Empty file removed common/cam.h
Empty file.
7 changes: 7 additions & 0 deletions common/conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef OCV_AR_CONF_H
#define OCV_AR_CONF_H

#define OCV_AR_CONF_PLATFORM_IOS
//#define #define OCV_AR_CONF_PLATFORM_ANDROID

#endif
8 changes: 0 additions & 8 deletions common/core.cpp

This file was deleted.

Empty file removed common/core.h
Empty file.
63 changes: 63 additions & 0 deletions common/detect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef OCV_AR_DETECT_H
#define OCV_AR_DETECT_H

#include <set>

#include "conf.h"
#include "types.h"
#include "marker.h"

using namespace std;

namespace ocv_ar {

class Detect {
public:

void setCamIntrinsics(cv::Mat &camIntrinsics);

void setFrameOutputLevel(FrameProcLevel level);

void setInputFrame(cv::Mat *frame);
cv::Mat *getOutputFrame() const { return outFrame; }

void processFrame();

set<Marker *> getMarkers() const { return markers; };

private:
void preprocess();

void performThreshold();

void threshPostProc();

void findContours();

void findMarkerCandidates();

void checkMarkerCandidates();

void discardDuplicateMarkers();

void estimatePositions();

void setOutputFrameOnReqProcLevel(FrameProcLevel reqLvl, cv::Mat *srcFrame = NULL);

int readMarkerCode(cv::Mat &img, int *validRot);

bool checkMarkerCode(const cv::Mat &m, int dir) const;
int markerCodeToId(const cv::Mat &m, int dir) const;

void drawMarker(cv::Mat &img, const Marker &m);


cv::Mat *inFrame;
cv::Mat *outFrame;

set<Marker *> markers;
};

}

#endif
60 changes: 60 additions & 0 deletions common/marker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef OCV_AR_MARKER_H
#define OCV_AR_MARKER_H

#include <vector>

#include "conf.h"
#include "marker.h"

using namespace std;

namespace ocv_ar {

typedef vector<cv::Point> PointVec;
typedef vector<cv::Point2f> Point2fVec;

class Marker {
public:
Marker(PointVec &pts);
Marker(Point2fVec &pts);

void setId(int newId) { id = newId; };
int getId() const { return id; };

Point2fVec getPoints() const { return points; };
void addPoint(cv::Point2f p) { points.push_back(p); };
void clearPoints() { points.clear(); };
void rotatePoints(int rot);

cv::Point2f getCentroid() const { return centroid; };
float getPerimeterRadius() const { return perimeterRad; };

const cv::Mat &getRVec() const { return rVec; };
const cv::Mat &getTVec() const { return tVec; };

void updatePoseMat(const cv::Mat &r, const cv::Mat &t);

// const glm::mat4 &getPoseMat() const { return poseMat; };
// const float *getPoseMatPtr() const { return poseMat.ptr<float>(); };

void sortPoints();
void calcShapeProperties();

private:
void init();

int id;

Point2fVec points;

cv::Point2f centroid;
float perimeterRad;

cv::Mat rVec;
cv::Mat tVec;
// glm::mat4 poseMat; // 4x4 matrix with model-view-transformation
};

}

#endif
9 changes: 9 additions & 0 deletions common/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef OCV_AR_TYPES_H
#define OCV_AR_TYPES_H

typedef enum _FrameProcLevel {
DEFAULT = -1,
PREPROC,
} FrameProcLevel;

#endif
7 changes: 7 additions & 0 deletions ocv_ar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef OCV_AR
#define OCV_AR

#include "common/conf.h"
#include "common/detect.h"

#endif

0 comments on commit 9e44747

Please sign in to comment.