PlotItemDialog::PlotItemDialog(PlotItem *item, QWidget *parent)
    : ViewItemDialog(item, parent), _plotItem(item), _defaultTagString("<Auto Name>") {

  Q_ASSERT(_plotItem);

  _store = kstApp->mainWindow()->document()->objectStore();

  setWindowTitle(tr("Edit Plot Item"));

  _contentTab = new ContentTab(this, _store);
  connect(_contentTab, SIGNAL(apply()), this, SLOT(contentChanged()));
  DialogPage *contentsPage = new DialogPage(this);
  contentsPage->setPageTitle(tr("Contents"));
  contentsPage->addDialogTab(_contentTab);
  addDialogPage(contentsPage, true);

  _labelTab = new LabelTab(_plotItem, this);
  _topLabelTab = new OverrideLabelTab(tr("Top Font"), this);
  _bottomLabelTab = new OverrideLabelTab(tr("Bottom Font"), this);
  _leftLabelTab = new OverrideLabelTab(tr("Left Font"), this);
  _rightLabelTab = new OverrideLabelTab(tr("Right Font"), this);
  _axisLabelTab = new OverrideLabelTab(tr("Axis Font"), this);

  _labelPage = new DialogPageTab(this);
  _labelPage->setPageTitle(tr("Labels"));
  _labelPage->addDialogTab(_labelTab);
  _labelPage->addDialogTab(_topLabelTab);
  _labelPage->addDialogTab(_bottomLabelTab);
  _labelPage->addDialogTab(_leftLabelTab);
  _labelPage->addDialogTab(_rightLabelTab);
  _labelPage->addDialogTab(_axisLabelTab);
  addDialogPage(_labelPage, true);

  connect(_labelTab, SIGNAL(apply()), this, SLOT(labelsChanged()));
  connect(_labelTab, SIGNAL(globalFontUpdate()), this, SLOT(globalFontUpdate()));

  connect(_topLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useTopDefaultChanged(bool)));
  connect(_bottomLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useBottomDefaultChanged(bool)));
  connect(_leftLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useLeftDefaultChanged(bool)));
  connect(_rightLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useRightDefaultChanged(bool)));
  connect(_axisLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useAxisDefaultChanged(bool)));

  _rangeTab = new RangeTab(_plotItem, this);
  DialogPage *rangePage = new DialogPage(this);
  rangePage->setPageTitle(tr("Range/Zoom"));
  rangePage->addDialogTab(_rangeTab);
  addDialogPage(rangePage, true);
  connect(_rangeTab, SIGNAL(apply()), this, SLOT(rangeChanged()));

  _xAxisTab = new AxisTab(this);
  _xAxisPage = new DialogPage(this);
  _xAxisPage->setPageTitle(tr("X-Axis"));
  _xAxisPage->addDialogTab(_xAxisTab);
  addDialogPage(_xAxisPage, true);
  connect(_xAxisTab, SIGNAL(apply()), this, SLOT(xAxisChanged()));

  _yAxisTab = new AxisTab(this);
  _yAxisTab->setAsYAxis();
  _yAxisPage = new DialogPage(this);
  _yAxisPage->setPageTitle(tr("Y-Axis"));
  _yAxisPage->addDialogTab(_yAxisTab);
  addDialogPage(_yAxisPage, true);
  connect(_yAxisTab, SIGNAL(apply()), this, SLOT(yAxisChanged()));

  _xMarkersTab = new MarkersTab(this);
  DialogPage *xMarkersPage = new DialogPage(this);
  xMarkersPage->setPageTitle(tr("X-Axis Markers"));
  xMarkersPage->addDialogTab(_xMarkersTab);
  addDialogPage(xMarkersPage, true);
  _xMarkersTab->setObjectStore(_store);
  connect(_xMarkersTab, SIGNAL(apply()), this, SLOT(xAxisPlotMarkersChanged()));

  _yMarkersTab = new MarkersTab(this);
  DialogPage *yMarkersPage = new DialogPage(this);
  yMarkersPage->setPageTitle(tr("Y-Axis Markers"));
  yMarkersPage->addDialogTab(_yMarkersTab);
  addDialogPage(yMarkersPage, true);
  _yMarkersTab->setObjectStore(_store);
  connect(yMarkersPage, SIGNAL(apply()), this, SLOT(yAxisPlotMarkersChanged()));

  // addRelations(); This tends to clutter the plot dialog, let's test skipping it

  setupContent();
  setupAxis();
  setupRange();
  setupLabels();
  setupMarkers();

  setSupportsMultipleEdit(true);

  if (_plotItem->descriptiveNameIsManual()) {
    setTagString(_plotItem->descriptiveName());
  } else {
    setTagString(_defaultTagString);
  }

  QList<PlotItem*> list = ViewItem::getItems<PlotItem>();
  clearMultipleEditOptions();
  foreach(PlotItem* plot, list) {
    addMultipleEditOption(plot->plotName(), plot->descriptionTip(), plot->shortName());
  }
Example #2
0
	bool BazARTracker::init(int xsize, int ysize, 
			const std::string& bazar_config_name,
			const std::string& camera_name)
	{
		
		/*OSGART*/
		ARParam  wparam;
	    // Set the initial camera parameters.
		cparamName = camera_name;
	    if(arParamLoad((char*)cparamName.c_str(), 1, &wparam) < 0) {
			std::cerr << "ERROR: Camera parameter load error." << std::endl;
			return false;
	    }
	    arParamChangeSize(&wparam, xsize, ysize,&(m_cparam->cparam));

		arInitCparam(&(m_cparam->cparam));
	    arParamDisp(&(m_cparam->cparam));
		

	/*BAZAR*/
		// load BazAR's configuration files and detector parameters
		if (!loadBazARConfig(bazar_config_name, &bazconf)) exit(0);
		// load BazAR's camera calibration file
		if (!loadBazARCamParams((char*)(bazconf.camCalFileName),&bazconf)) exit(0);

		// init bazar tracker
		matCameraRT4_4 = cvCreateMat(4, 4, CV_64F); //64 bit double precision float
		g_matIntrinsic   = cvCreateMat(3, 3, CV_64F);
		
		// output windows
		if (getDebugMode()){
			cvNamedWindow("Gray", CV_WINDOW_AUTOSIZE);
			cvNamedWindow("Result_BAZAR", CV_WINDOW_AUTOSIZE);
		}
		// fine tuning for accuracy - careful!!
		detector.ransac_dist_threshold = (float)bazconf.ransac_dist_threshold;
		detector.max_ransac_iterations = (float)bazconf.max_ransac_iterations;
		detector.non_linear_refine_threshold = (float)bazconf.non_linear_refine_threshold;
		detector.match_score_threshold = (float)bazconf.match_score_threshold;	// A lower threshold will allow detection in harder conditions, but
																				// might lead to false positives
		// Train or load classifier
		if(!detector.build_with_cache(
			// hse25: no hard coded stuff :) -- jaja
			(char*)(bazconf.modelFileName),	// mode image file name
			400,               // maximum number of keypoints on the model
			32,                // patch size in pixels
			3,                 // yape radius. Use 3,5 or 7.
			16,                // number of trees for the classifier. Somewhere between 12-50
			3                  // number of levels in the gaussian pyramid
			))
		{
		cerr << "BazARTracker: Unable to load the model image " << (char*)(bazconf.modelFileName) <<" or its classifier.\n";
		return false;
		}
		 
		// set camera parameters for BAZAR
		char	*camCal = (char*)(bazconf.camCalFileName);
		char	*camExt = (char*)(bazconf.camExtFileName);
		if(!augment.LoadOptimalStructureFromFile(camCal, camExt))
		{
			std::cerr << "BazARTracker: couldn't load camera parameters: " << camCal << " " << camExt << std::endl;
			return false;
		}
		
		// image buffers needed for detection, conversion..
		image     = cvCreateImage(cvSize(xsize, ysize), IPL_DEPTH_8U, 4); // captured image
		gray      = cvCreateImage(cvSize(xsize, ysize), IPL_DEPTH_8U, 1); // detector input
		display   = cvCreateImage(cvSize(xsize, ysize), IPL_DEPTH_8U, 4); // debug
		
		// use bazar's camera calibration 
		m_cparam->cparam.mat[0][0] = bazconf.camCalMatrix[0][0];	m_cparam->cparam.mat[0][1] = bazconf.camCalMatrix[0][1];    m_cparam->cparam.mat[0][2] = bazconf.camCalMatrix[0][2];
		m_cparam->cparam.mat[1][0] = bazconf.camCalMatrix[1][0];	m_cparam->cparam.mat[1][1] = bazconf.camCalMatrix[1][1];    m_cparam->cparam.mat[1][2] = bazconf.camCalMatrix[1][2];
		m_cparam->cparam.mat[2][0] = bazconf.camCalMatrix[2][0];	m_cparam->cparam.mat[2][1] = bazconf.camCalMatrix[2][1];    m_cparam->cparam.mat[2][2] = bazconf.camCalMatrix[2][2];
		
		for(int i=0; i<3; i++)
		{
			for(int j=0; j<3; j++)
			{
				cvmSet(g_matIntrinsic, i, j, m_cparam->cparam.mat[i][j]);
			}
		}
	// end BAZAR
	  
		setProjection(10.0f, 8000.0f);
		setDebugMode(m_debugmode);
		
		setupMarkers();

		// Success
		return true;
	}
Example #3
0
int main(int argc, char **argv)
{
    char                glutGamemode[32];
    char                *cpara                                 = NULL;
    char                cparaDefault[]                         = "Data/camera_para.dat";
    char                *vconf                                 = NULL;
    int                 patt_names_count                       = 0;
    char                *patt_names[CHECK_ID_MULTIMARKERS_MAX] = {NULL};
    ARdouble            pattRatio                              = (ARdouble)AR_PATT_RATIO;
    AR_MATRIX_CODE_TYPE matrixCodeType                         = AR_MATRIX_CODE_TYPE_DEFAULT;
    int                 labelingMode                           = AR_DEFAULT_LABELING_MODE;
    int                 patternDetectionMode                   = AR_DEFAULT_PATTERN_DETECTION_MODE;
    int                 i, gotTwoPartOption;
    float               tempF;
    int                 tempI;


    //
    // Library inits.
    //

    glutInit(&argc, argv);

    //
    // Startup options.
    //

    i = 1; // argv[0] is name of app, so start at 1.

    while (i < argc)
    {
        gotTwoPartOption = FALSE;
        // Look for two-part options first.
        if ((i + 1) < argc)
        {
            if (strcmp(argv[i], "--vconf") == 0)
            {
                i++;
                vconf            = argv[i];
                gotTwoPartOption = TRUE;
            }
            else if (strcmp(argv[i], "--cpara") == 0)
            {
                i++;
                cpara            = argv[i];
                gotTwoPartOption = TRUE;
            }
            else if (strcmp(argv[i], "--pattRatio") == 0)
            {
                i++;
                if (sscanf(argv[i], "%f", &tempF) == 1 && tempF > 0.0f && tempF < 1.0f)
                    pattRatio = (ARdouble)tempF;
                else
                    ARLOGe("Error: argument '%s' to --pattRatio invalid.\n", argv[i]);

                gotTwoPartOption = TRUE;
            }
            else if (strcmp(argv[i], "--pattSize") == 0)
            {
                i++;
                if (sscanf(argv[i], "%d", &tempI) == 1 && tempI >= 16 && tempI <= AR_PATT_SIZE1_MAX)
                    gPattSize = tempI;
                else
                    ARLOGe("Error: argument '%s' to --pattSize invalid.\n", argv[i]);

                gotTwoPartOption = TRUE;
            }
            else if (strcmp(argv[i], "--pattCountMax") == 0)
            {
                i++;
                if (sscanf(argv[i], "%d", &tempI) == 1 && tempI > 0)
                    gPattCountMax = tempI;
                else
                    ARLOGe("Error: argument '%s' to --pattSize invalid.\n", argv[i]);

                gotTwoPartOption = TRUE;
            }
            else if (strcmp(argv[i], "--borderSize") == 0)
            {
                i++;
                if (sscanf(argv[i], "%f", &tempF) == 1 && tempF > 0.0f && tempF < 0.5f)
                    pattRatio = (ARdouble)(1.0f - 2.0f * tempF);
                else
                    ARLOGe("Error: argument '%s' to --borderSize invalid.\n", argv[i]);

                gotTwoPartOption = TRUE;
            }
            else if (strcmp(argv[i], "--matrixCodeType") == 0)
            {
                i++;
                if (strcmp(argv[i], "AR_MATRIX_CODE_3x3") == 0)
                    matrixCodeType = AR_MATRIX_CODE_3x3;
                else if (strcmp(argv[i], "AR_MATRIX_CODE_3x3_HAMMING63") == 0)
                    matrixCodeType = AR_MATRIX_CODE_3x3_HAMMING63;
                else if (strcmp(argv[i], "AR_MATRIX_CODE_3x3_PARITY65") == 0)
                    matrixCodeType = AR_MATRIX_CODE_3x3_PARITY65;
                else if (strcmp(argv[i], "AR_MATRIX_CODE_4x4") == 0)
                    matrixCodeType = AR_MATRIX_CODE_4x4;
                else if (strcmp(argv[i], "AR_MATRIX_CODE_4x4_BCH_13_9_3") == 0)
                    matrixCodeType = AR_MATRIX_CODE_4x4_BCH_13_9_3;
                else if (strcmp(argv[i], "AR_MATRIX_CODE_4x4_BCH_13_5_5") == 0)
                    matrixCodeType = AR_MATRIX_CODE_4x4_BCH_13_5_5;
                else if (strcmp(argv[i], "AR_MATRIX_CODE_5x5") == 0)
                    matrixCodeType = AR_MATRIX_CODE_5x5;
                else if (strcmp(argv[i], "AR_MATRIX_CODE_6x6") == 0)
                    matrixCodeType = AR_MATRIX_CODE_6x6;
                else if (strcmp(argv[i], "AR_MATRIX_CODE_GLOBAL_ID") == 0)
                    matrixCodeType = AR_MATRIX_CODE_GLOBAL_ID;
                else
                    ARLOGe("Error: argument '%s' to --matrixCodeType invalid.\n", argv[i]);

                gotTwoPartOption = TRUE;
            }
            else if (strcmp(argv[i], "--labelingMode") == 0)
            {
                i++;
                if (strcmp(argv[i], "AR_LABELING_BLACK_REGION") == 0)
                    labelingMode = AR_LABELING_BLACK_REGION;
                else if (strcmp(argv[i], "AR_LABELING_WHITE_REGION") == 0)
                    labelingMode = AR_LABELING_WHITE_REGION;
                else
                    ARLOGe("Error: argument '%s' to --labelingMode invalid.\n", argv[i]);

                gotTwoPartOption = TRUE;
            }
            else if (strcmp(argv[i], "--patternDetectionMode") == 0)
            {
                i++;
                if (strcmp(argv[i], "AR_TEMPLATE_MATCHING_COLOR") == 0)
                    patternDetectionMode = AR_TEMPLATE_MATCHING_COLOR;
                else if (strcmp(argv[i], "AR_TEMPLATE_MATCHING_MONO") == 0)
                    patternDetectionMode = AR_TEMPLATE_MATCHING_MONO;
                else if (strcmp(argv[i], "AR_MATRIX_CODE_DETECTION") == 0)
                    patternDetectionMode = AR_MATRIX_CODE_DETECTION;
                else if (strcmp(argv[i], "AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX") == 0)
                    patternDetectionMode = AR_TEMPLATE_MATCHING_COLOR_AND_MATRIX;
                else if (strcmp(argv[i], "AR_TEMPLATE_MATCHING_MONO_AND_MATRIX") == 0)
                    patternDetectionMode = AR_TEMPLATE_MATCHING_MONO_AND_MATRIX;
                else
                    ARLOGe("Error: argument '%s' to --patternDetectionMode invalid.\n", argv[i]);

                gotTwoPartOption = TRUE;
            }
        }

        if (!gotTwoPartOption)
        {
            // Look for single-part options.
            if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "-h") == 0)
            {
                usage(argv[0]);
            }
            else if (strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "-v") == 0)
            {
                ARLOG("%s version %s\n", argv[0], AR_HEADER_VERSION_STRING);
                exit(0);
            }
            else if (strncmp(argv[i], "-border=", 8) == 0)
            {
                if (sscanf(&(argv[i][8]), "%f", &tempF) == 1 && tempF > 0.0f && tempF < 0.5f)
                    pattRatio = (ARdouble)(1.0f - 2.0f * tempF);
                else
                    ARLOGe("Error: argument '%s' to -border= invalid.\n", argv[i]);
            }
            else
            {
                if (patt_names_count < CHECK_ID_MULTIMARKERS_MAX)
                {
                    patt_names[patt_names_count] = argv[i];
                    patt_names_count++;
                }

                // } else {
                //    ARLOGe("Error: invalid command line argument '%s'.\n", argv[i]);
                //    usage(argv[0]);
            }
        }

        i++;
    }

    //
    // Video setup.
    //

    if (!cpara)
        cpara = cparaDefault;

    if (!setupCamera(cpara, vconf, &gCparamLT, &gARHandle, &gAR3DHandle))
    {
        ARLOGe("main(): Unable to set up AR camera.\n");
        exit(-1);
    }

    //
    // AR init.
    //

    arSetPatternDetectionMode(gARHandle, patternDetectionMode);
    arSetLabelingMode(gARHandle, labelingMode);
    arSetPattRatio(gARHandle, pattRatio);
    arSetMatrixCodeType(gARHandle, matrixCodeType);

    //
    // Graphics setup.
    //

    // Set up GL context(s) for OpenGL to draw into.
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    if (!windowed)
    {
        if (windowRefresh)
            sprintf(glutGamemode, "%ix%i:%i@%i", windowWidth, windowHeight, windowDepth, windowRefresh);
        else
            sprintf(glutGamemode, "%ix%i:%i", windowWidth, windowHeight, windowDepth);

        glutGameModeString(glutGamemode);
        glutEnterGameMode();
    }
    else
    {
        glutInitWindowSize(gCparamLT->param.xsize, gCparamLT->param.ysize);
        glutCreateWindow(argv[0]);
    }

    // Setup ARgsub_lite library for current OpenGL context.
    if ((gArglSettings = arglSetupForCurrentContext(&(gCparamLT->param), arVideoGetPixelFormat())) == NULL)
    {
        ARLOGe("main(): arglSetupForCurrentContext() returned error.\n");
        cleanup();
        exit(-1);
    }

    arglSetupDebugMode(gArglSettings, gARHandle);
    arUtilTimerReset();

    // Load marker(s).
    if (!setupMarkers(patt_names_count, (const char**)patt_names, gMultiConfigs, gARHandle, &gARPattHandle))
    {
        ARLOGe("main(): Unable to set up AR marker(s).\n");
        cleanup();
        exit(-1);
    }

    gMultiConfigCount = patt_names_count;

    // Register GLUT event-handling callbacks.
    // NB: mainLoop() is registered by Visibility.
    glutDisplayFunc(Display);
    glutReshapeFunc(Reshape);
    glutVisibilityFunc(Visibility);
    glutKeyboardFunc(Keyboard);

    glutMainLoop();

    return (0);
}
bool
ARToolKit4NFTTracker::init(int xsize,int ysize,
						   const std::string& pattlist_name,const std::string& camera_name)
{
	ARParam  wparam;

    // Set the initial camera parameters.

    if(arParamLoad((char*)camera_name.c_str(), 1, &wparam) < 0) {
		std::cerr << "ERROR: Camera parameter load error." << std::endl;
		return false;
    }
    arParamChangeSize(&wparam, xsize, ysize, &cparam);

	std::cout << "*** Camera Parameter ***" << std::endl;
    arParamDisp( &cparam );

	if( (arHandle = arCreateHandle(&cparam)) == NULL ) 
	{
		std::cerr << "ERROR: arCreateHandle." << std::endl;
        return false;
    }

	int pixFormat = AR_PIXEL_FORMAT_BGRA;

    if( arSetPixelFormat(arHandle, pixFormat) < 0 ) 
	{
        std::cerr << "Error: arSetPixelFormat." << std::endl;
        return false;
    }

	if( arSetDebugMode(arHandle, AR_DEBUG_DISABLE) < 0 ) 
	{
        std::cerr << "Error: arSetDebugMode." << std::endl;
        return false;
    }

	if( arSetLabelingThresh(arHandle,threshold) < 0 ) 
	{
        std::cerr << "Error: arSetLabelingThresh." << std::endl;
        return false;
    }

	arSetMarkerExtractionMode( arHandle, AR_NOUSE_TRACKING_HISTORY );

    if( (ar3DHandle=ar3DCreateHandle(&cparam)) == NULL ) 
	{
         std::cerr << "Error: ar3DCreateHandle." << std::endl;
         return false;
    }
    if( (arPattHandle=arPattCreateHandle()) == NULL ) 
	{
         std::cerr << "Error: arPattCreateHandle." << std::endl;
         return false;
    }
	setProjection(10.0f, 10000.0f);

	//INIT NFT
	int	matchingImageMode = AR2_MATCHING_FRAME_IMAGE;
	int	matchingMethod    = AR2_MATCHING_FINE;

	int	debugMode         = 0;
    
	ar2Handle = ar2CreateHandle( &cparam, pixFormat );

	ar2ChangeMacthingImageMode( ar2Handle, matchingImageMode );
	ar2ChangeMacthingMethod( ar2Handle, matchingMethod );
	ar2ChangeDebugMode( ar2Handle, debugMode );

	//arFittingMode   = AR_FITTING_TO_IDEAL;
	//arImageProcMode = AR_IMAGE_PROC_IN_FULL;
	if (!setupMarkers(pattlist_name)) {
		std::cerr << "ERROR: Marker setup failed." << std::endl;
		return false;
	}	

	return true;
}