00001 #include "TestAlg.h"
00002 #include "tcastypes.h"
00003 #include <iostream>
00004 #include <math.h>
00005
00006 TestAlg::TestAlg()
00007 {
00008 algName = "Invert Algorithm";
00009 srand( time(NULL) );
00010 }
00011
00012 TestAlg::~TestAlg()
00013 {
00014 }
00015
00016 void TestAlg::processFrame(QImage *frame)
00017 {
00018
00019
00020
00021
00022
00023
00024
00025 QImage newImage = frame->copy();
00026 newImage.invertPixels();
00027 emit imageReady(&newImage);
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 int j = 1 + (int) (100.0 * (rand() / (RAND_MAX + 1.0)));
00039 if (j <= 5)
00040 {
00041
00042 int t = 1 + (int) (100.0 * (rand() / (RAND_MAX + 1.0)));
00043 int d = 1 + (int) (100.0 * (rand() / (RAND_MAX + 1.0)));
00044 int a = 1 + (int) (200.0 * (rand() / (RAND_MAX + 1.0)));
00045 a = a - 100;
00046 threatType typ;
00047 trendDir dir;
00048 if (t <25 ) {typ = threatOther; emit foundOther();}
00049 else if ( t >= 25 && t < 50) {typ = threatProximate; emit foundProximate();}
00050 else if ( t >= 50 && t < 75) {typ = threatIntruding; emit foundIntruding();}
00051 else {typ = threatReal; emit foundReal();}
00052
00053 if (d <= 50) dir = ascending;
00054 else dir = descending;
00055
00056
00057 int w = 1 + (int) (500.0 * (rand() / (RAND_MAX + 1.0)));
00058 int h = 1 + (int) (400.0 * (rand() / (RAND_MAX + 1.0)));
00059
00060
00061
00062
00063
00064 unsigned long key;
00065
00066 if ( h <= 200)
00067 {
00068 int ang = 1 + (int) (180.0 * (rand() / (RAND_MAX + 1.0))) - 90;
00069
00070 int orient= 1 + (int) (360.0 * (rand() / (RAND_MAX + 1.0)));
00071 trendDir n = none;
00072 emit foundObstacle(typ,n,a,ang,orient,key);
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082 emit foundObstacle(typ,dir,a,w,h,key);
00083 QString str = "Found obstacle at ";
00084 str.append(QString::number(w));
00085 str.append(",");
00086 str.append(QString::number(h));
00087 str.append(" with relative altitude of ");
00088 str.append(QString::number(a));
00089 emit displayMessage(&str);
00090 }
00091 }