void HandDetector::FindConvexityDefects(vector<Vec4i> ConvexityDefectSet, vector<Point> HandContour, Mat& LiveFrame, Point2f COM, int TiltAngle) { vector<Point> FingerTips; Point2f HandCenter; float radius; int fingers=0; //minEnclosingCircle(HandContour,HandCenter,radius); //Rect contourRect = boundingRect(HandContour); //circle(LiveFrame,HandCenter,10,CV_RGB(0,0,255),2,8); //rectangle(LiveFrame, contourRect, Scalar(0,0,255), 3); //vector<Point> palmCircle; for (int i = 0; i < ConvexityDefectSet.size(); i++) { int startId = ConvexityDefectSet[i].val[0]; Point ptStart(HandContour[startId]); int endId = ConvexityDefectSet[i].val[1]; Point ptEnd(HandContour[endId]); int farId = ConvexityDefectSet[i].val[2]; Point ptFar(HandContour[farId]); double depth = (double)((ConvexityDefectSet[i].val[3]) / 256); //for getting real pixel values //cout << "depth" << depth << endl; //display start points //circle(original,ptStart,5,CV_RGB(255,0,0),2,8); //display all end points //circle(original, ptEnd, 5, CV_RGB(255, 255, 0), 2, 8); //display all far points //circle(LiveFrame,ptFar,5,CV_RGB(255,255,0),2,8); //circle(LiveFrame, HandCenter, radius, cv::Scalar(0,255,255),2); if (depth > 10 && ptStart.y < COM.y)// { circle(LiveFrame,ptStart,5,CV_RGB(255,0,0),2,8); //circle(LiveFrame, ptStart, 4, CV_RGB(255, 0,0), 4); FingerTips.push_back(ptStart); fingers++; //palmCircle.push_back(ptStart); } } if(mMouseControl) { InitMouseControl(LiveFrame,FingerTips,COM,TiltAngle); } if(mSwipeON) { Point tempCOM; tempCOM.x = COM.x; tempCOM.y = COM.y; mSwipeGesture.SwipeInit(tempCOM, LiveFrame); } //cout<<"Fingers = "<<fingers<<endl; }
void main( int argc, char** argv) { //struct Position Pos; int Ix; strcpy( ConfigFile, "config.dat"); Parity = NoneParity; DataBits = 8; StopBits = 1; CalledByGuideFlag = No; KeepGoingFlag = No; ReadSlewFlag = No; StartScrollFlag = No; /* if '-k' and '-s' (after full init): slew to Ra, Dec in slew.dat and keep going, exiting when desired, writing slew_out.dat file; if '-k' (before full init): (no slew.dat), keep going until centered on init position, write slew_out.dat file and exit; if '-s': slew to Ra, Dec in slew.dat and exit, writing slew_out.dat file; if no '-k' and no '-s': write slew_out.dat file and exit; if -c, then use following string as configuration file name, ie scope.exe -c config.dat will result in config.dat being used if -x, then use following string as scroll file name, and execute scroll file upon program startup, ie scope.exe -x nan.scr will cause nan.scr to be loaded and started */ /* argv[0] is name of executing program */ for( Ix = 1; Ix < argc; Ix++) if( argv[Ix][0] == '-') if( strcmpi( &argv[Ix][1], "GUIDE") == 0) CalledByGuideFlag = Yes; else if( argv[Ix][1] == 'k') KeepGoingFlag = Yes; else if( argv[Ix][1] == 's') ReadSlewFlag = Yes; else if( (argv[Ix][1] == 'c' || argv[Ix][1] == 'C') && Ix < argc-1) strcpy( ConfigFile, argv[Ix+1]); else if( (argv[Ix][1] == 'x' || argv[Ix][1] == 'X') && Ix < argc-1) { strcpy( ScrollFilename, argv[Ix+1]); StartScrollFlag = Yes; } InitCommonVars(); ReadConfig(); /* Pos.Ra = Pos.Dec = 0; applyCorrectionsFromDataFileCoordYearToEpochNow(&Pos); printf("\n%f %f %f %f %f %f %f %f", Pos.Precession.A*RadToArcsec, Pos.Precession.Z*RadToArcsec, Pos.Nutation.A*RadToArcsec, Pos.Nutation.Z*RadToArcsec, Pos.AnnualAberration.A*RadToArcsec, Pos.AnnualAberration.Z*RadToArcsec, Pos.Ra*RadToArcsec, Pos.Dec*RadToArcsec); ContMsgRoutine(); */ /* HsRecFile = fopen( HsRecFilename, "w"); if( HsRecFile == NULL) BadExit( strcat( "Could not create ", HsRecFilename)); HsRecIx = 0; */ /* InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); InitConvert(); TestConvert(); getch(); TestAltAltAzTrack(); */ if( DisplayOpeningMsgs) { printf( "\nCopyright BBAstroDesigns Inc. 2009\n"); printf( "\nLIMITED WARRANTY This software is provided ``as is'' and any express or"); printf( "\nimplied warranties, including, but not limited to, the implied warranties"); printf( "\nof merchantability and fitness for a particular purpose are disclaimed."); printf( "\nIn no event shall BBAstroDesigns be liable for any direct, indirect,"); printf( "\nincidental, special, exemplary, nor consequential damages (including, but"); printf( "\nnot limited to, procurement of substitute goods or services, loss of use,"); printf( "\ndate, or profits, or business interruption) however caused and on any"); printf( "\ntheory of liability, whether in contract, strict liability, or tort"); printf( "\n(including negligence or otherwise) arising in any way out of the use of"); printf( "\nthis software, even if advised of the possibility of such damage.\n"); printf( "\nThis software licensed under the GNU GENERAL PUBLIC LICENSE. You may"); printf( "\ndistribute this software per the GNU GPL. See the enclosed gpl.txt.\n\n"); ContMsgRoutine(); } if( DisplayOpeningMsgs) printf( "\ncalled by guide: %d, keep_going: %d, read slew.dat file %d", CalledByGuideFlag, KeepGoingFlag, ReadSlewFlag); /* if( strcmpi( TestString, "TestSerial") == 0) { InitSerial( EncoderComPort, EncoderBaudRate, Parity, DataBits, StopBits); TestSerial( EncoderComPort); CloseSerial( EncoderComPort); } */ /* else if( strcmpi( TestString, "TestVideo") == 0) { InitVideo( DisplayOpeningMsgs); TestVideo(); } */ /* else if( strcmpi( TestString, "TestATimes") == 0) { InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); TestTimes(); } */ /* else if( strcmpi( TestString, "TestParallelPort") == 0) { InitPPort(); TestPPort(); ClosePPort(); } */ /* else if( strcmpi( TestString, "TestRefract") == 0) { InitRefract(); TestRefract(); } */ /* else if( strcmpi( TestString, "TestMouse") == 0) { TestMouse(); } */ /* else if( strcmpi( TestString, "TestEncoders") == 0) { InitSerial( EncoderComPort, EncoderBaudRate, Parity, DataBits, StopBits); InitEncoders(); TestEncoders(); CloseSerial( EncoderComPort); } */ /* else if( strcmpi( TestString, "TestHandpad") == 0) { InitPPort(); InitializeHandpad(); TestHandpad(); ClosePPort(); } */ /* else if( strcmpi( TestString, "TestConversion") == 0) { InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); InitConvert(); TestConvert(); } */ /* else if( strcmpi( TestString, "TestAltOffset") == 0) { InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); InitConvert(); TestAltOffset(); } */ /* else if( strcmpi( TestString, "TestIACA") == 0) { InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); TestIACA(); InitIACA(); } */ /* else if( strcmpi( TestString, "WritePWMValues") == 0) { InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); InitVideo( DisplayOpeningMsgs); InitPPort(); InitMotors(); WritePWMValues(); CloseSteppers(); ClosePPort(); } else */ { if( strcmpi( TestString, "NoTest") != 0 && strcmpi( TestString, "PreloadGuidexx.dat") != 0 && strcmpi( TestString, "Track") != 0) { if( DisplayOpeningMsgs) printf( "\nsetting unrecognized TestString to 'NoTest'"); strcpy( TestString, "NoTest"); } InitSerial( EncoderComPort, EncoderBaudRate, Parity, DataBits, StopBits); InitEncoders(); InitMouseControl(); InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg); InitVideo( DisplayOpeningMsgs); InitPPort(); InitializeHandpad(); InitMotors(); InitConvert(); InitRefract(); InitPEC(); InitGuide(); if( strcmpi( TestString, "PreloadGuidexx.dat") == 0) { LoadGuideAlts(); LoadGuideAzs(); } InitIACA(); InitLX200Input(); InitHPEvent(); if( !CalledByGuideFlag || (CalledByGuideFlag && (KeepGoingFlag || ReadSlewFlag))) { InitKBEvent(); if( ReadSlewFlag) InputEquatSlewDat(); if( StartScrollFlag) LoadScrollFileFromFile(); if( strcmpi( TestString, "Track") == 0) Start2MotorTrackWithDefaultValues(); while( !QuitFlag) { SequentialTaskController(); /* GrandTourFlag used to flag next object: set in ProcessHPEventsModeSwitch() */ if( GrandTourLoaded && GrandTourFlag) ProcessGrandTour(); else if( ScrollLoaded && ScrollFlag) ProcessScroll(); else if( HPPolarAlignLoaded && HPPolarAlignFlag) ProcessHPPolarAlign(); else { if( UseMouseFlag && ProcessMouseEvent()) ; else if( KeyStroke) ProcessKBEvents(); else ProcessHPEvents(); } } CloseKBEvent(); if( DisplayOpeningMsgs) { AskAndWriteConfig(); WriteLogFile(); } } CloseSteppers(); ClosePPort(); CloseEncoderResetLogFile(); CloseSerial( EncoderComPort); CloseSerial( LX200ComPort); if( CalledByGuideFlag) WriteAltazSlewOutFile(); CloseMouseControl(); } /* for( Ix = 0; Ix < HsRecSize; Ix++) fprintf( HsRecFile, "%8ld %8ld\n", HsRec[Ix].A, HsRec[Ix].Z); // first position is index 0 fprintf( HsRecFile, " last entry in circular queue at position %d", HsRecIx); fclose( HsRecFile); */ }