-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
146 additions
and
8 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |