double-hit-balls/game/main_code.h

120 lines
2.6 KiB
C++
Executable File

#ifndef MAIN_CODE_H_INCLUDED
#define MAIN_CODE_H_INCLUDED
#ifdef TARGET_ANDROID
#include "android_api.h"
#endif
#ifdef TARGET_WIN32
#define NOMINMAX 1
#include <Windows.h>
#undef NOMINMAX
#endif
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "boost/shared_ptr.hpp"
#include "boost/thread/thread.hpp"
#include "boost/assign.hpp"
#include "boost/bind.hpp"
#include "include/Engine.h"
#include "boost/signals2.hpp"//Signal must be included after asio
#include "../windows/DoubleHitBalls-win/DoubleHitBalls-win/FaceLandmarkDetector.h"
#include "../windows/DoubleHitBalls-win/DoubleHitBalls-win/ValueSmoother.h"
struct FaceStruct
{
SE::Vector2f center;
SE::Vector2f size;
ValueSmoother centerXSmoother;
ValueSmoother centerYSmoother;
ValueSmoother sizeWidthSmoother;
ValueSmoother sizeHeightSmoother;
std::array<SE::Vector2f, LANDMARK_POINT_COUNT> preds;
//std::vector<std::array<SE::Vector2f, LANDMARK_POINT_COUNT>> historicalPreds;
std::vector<cv::Point3f> modelPoints;
cv::Mat rotationVector;
cv::Mat translationVector;
cv::Mat rotationMatrix;
cv::Mat poseMatrix;
cv::Mat eulerAngles;
std::vector<cv::Point3d> boxModelSrc;
std::vector<cv::Point2d> boxModelDst;
ValueSmoother rotationVectorSmoothers[3];
ValueSmoother translationVectorSmoothers[3];
std::vector<cv::Point3f> noseEndPoint3d;
std::vector<cv::Point2f> noseEndPoint2d;
FaceStruct();
FaceStruct(const std::array<cv::Point2f, LANDMARK_POINT_COUNT>& fromPreds, cv::Mat& cameraMatrix, cv::Mat& distortionCoefficients);
void CalcFromPreds(cv::Mat& cameraMatrix, cv::Mat& distortionCoefficients);
void ApplyPreds(const std::array<cv::Point2f, LANDMARK_POINT_COUNT>& fromPred, cv::Mat& cameraMatrix, cv::Mat& distortionCoefficientss);
void InnerApplyPreds(const std::array<cv::Point2f, LANDMARK_POINT_COUNT>& fromPreds);
};
using namespace SE;
extern const std::string CONST_LOADING_BACKGROUND_BLACK;
class TMyApplication : public TApplication
{
protected:
bool Inited;
std::array<TRenderPair, MAX_FACE_COUNT> faceRenderPair;
public:
TMyApplication() : TApplication(), Inited(false) { }
virtual void InnerInit();
virtual void InnerDeinit();
virtual void InnerDraw();
virtual void InnerUpdate(size_t dt);
bool IsInited();
virtual void InnerOnTapDown(Vector2f p);
virtual void InnerOnTapUp(Vector2f p);
virtual void InnerOnTapUpAfterMove(Vector2f p);
virtual void InnerOnMove(Vector2f p, Vector2f shift);
virtual void OnFling(Vector2f v);
};
extern TMyApplication* Application;
#endif