Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Signed-off-by: SAL (Save A Life) <[email protected]>
  • Loading branch information
whatheheckisthis authored Jul 14, 2024
1 parent d0eb5f1 commit c8c7588
Show file tree
Hide file tree
Showing 19 changed files with 2,026 additions and 0 deletions.
530 changes: 530 additions & 0 deletions Android.mk

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := all
APP_PLATFORM := android-18
APP_OPTIM := release

51 changes: 51 additions & 0 deletions LaneCalculations.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

#include "LaneCalculations.h"
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include <android/log.h>

// Global static pointer used to ensure a single instance of the class.
LaneCalculations* LaneCalculations::m_pInstance = NULL;

/** This function is called to create an instance of the class.
Calling the constructor publicly is not allowed. The constructor
is private and is only called by this Instance function.
*/

LaneCalculations* LaneCalculations::Instance()
{
if (!m_pInstance) // Only allow one instance of class to be generated.
m_pInstance = new LaneCalculations;

return m_pInstance;
}


double LaneCalculations::calculateMeanLateralPosition()
{
return LaneCalculations::Instance()->sumLateralPosition/LaneCalculations::Instance()->countLateralPosition;

}

double LaneCalculations::calculateSDLP()
{
double mean = calculateMeanLateralPosition();

double sumOfVariance = 0;
for(int i=0; i< LaneCalculations::Instance()->countLateralPosition; i++)
{
double temp1 = (LaneCalculations::Instance()->arrayLateralPosition[i] - mean) * (LaneCalculations::Instance()->arrayLateralPosition[i] - mean);
sumOfVariance += temp1;


}

double variance = sumOfVariance/LaneCalculations::Instance()->countLateralPosition;
double sdlp = sqrt(variance); //dividing to calculate sdlp with respect to single lane
sdlp = floor(sdlp*100 + 0.5)/100; //rounding off to 2 d.p


return sdlp;
}

66 changes: 66 additions & 0 deletions LaneCalculations.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*------------------------------------------------------------------------------------------*\
Logging lane metrics to help in understanding driver's behavior aka SDLP
\*------------------------------------------------------------------------------------------*/

//#if !defined LINEF
//#define LINEF

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include <android/log.h>

#define PI 3.1415926

using namespace cv;
using namespace std;

class LaneCalculations {

private:

LaneCalculations()//:sumLateralPosition(0), meanLateralPosition(0), countLateralPosition(0)
{
sumLateralPosition = 0;
meanLateralPosition = 0;
countLateralPosition = 0;
arrayLateralPosition = new double[50000];
__android_log_print(ANDROID_LOG_ERROR, "LANE Calculations", "Constructur : %s", "Yes called");

};

LaneCalculations(LaneCalculations const&){};
LaneCalculations& operator = (LaneCalculations const&){};
static LaneCalculations* m_pInstance;



// LineFinder() : deltaRho(1), deltaTheta(PI/180), minVote(10), minLength(0.), maxGap(0.) {}


public :

//Mean Lateral Position value
double sumLateralPosition;
double meanLateralPosition;
int countLateralPosition;

//Standard Deviation of Lateral Position (SDLP)
double* arrayLateralPosition;

static LaneCalculations* Instance();

double calculateMeanLateralPosition();
double calculateSDLP();








};

//#endif
Loading

0 comments on commit c8c7588

Please sign in to comment.