Exemplo n.º 1
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
    setupUi(this);
    initialize();							// 初始化
    setupWindows();
    setupConnections();
    initializeProcessTab();
    initializeFilterTab();
    setDisplayTab();
    setColourButtons();
    setDoingPIV();
    initializeDataQualityTab();
    initializeViewTab();
}
Exemplo n.º 2
0
bool initialize()
{
	REQUIRE(RBConfig::initialize(CONFIG_FILENAME));
	REQUIRE(Logger::initialize(LOG_COUT | LOG_TIMESTAMP_SHORT));
	REQUIRE(display.init());
	REQUIRE(audio.init());
	ms_per_frame = RBConfig::getMSPerFrame();

	keys     = new Keyboard;
	mouse    = new Mouse;
	painter  = new RBPainter;
	setupWindows();

	stringstream welcome;
	Logger::log("Welcome to Roguebud V. %s.",RBConfig::getVersion().c_str());

	return true;
}
Exemplo n.º 3
0
	bool CGameFinishedState::init()
	{
		log_trace(LOG_GAMEFINISHEDSTATE,"Init\n");

		CApplicationState::init();

		m_menuWindow = CEGUI::WindowManager::getSingletonPtr()->loadLayoutFromFile("GameEnd.layout");

		setupWindows();

		setupAnimatons();

		//Sounds & music

		Common::Sound::CSound::getSingletonPtr()->addSound("Button2.wav","buttonSoundFinished");
		Common::Sound::CSound::getSingletonPtr()->addSound("SoundIntro2.wav","buttonHoverFinished");
		Common::Sound::CSound::getSingletonPtr()->addSound("Intro1.wav","introFinishedSound");

		return true;
	}
Exemplo n.º 4
0
int main()
{
    //recordVideoFrames()

    cv::Mat3b img_top    = cv::imread("photos/IMG_6216.JPG", cv::IMREAD_COLOR);
    cv::Mat3b img_bottom = cv::imread("photos/IMG_6217.JPG", cv::IMREAD_COLOR);

    std::vector<cv::Point2f> points_top    = findLabelPositions(img_top);
    std::vector<cv::Point2f> points_bottom = findLabelPositions(img_bottom);

    Camera cam = solveCamera(points_top, points_bottom, img_top.size());
    const float label_width = 0.9f;
    analyzeVideo("video1", cam, label_width);

    setupWindows(img_bottom.size());

    std::vector<cv::Scalar> colors_top    = readLabelColors(img_top, points_top);
    std::vector<cv::Scalar> colors_bottom = readLabelColors(img_bottom, points_bottom);

    std::vector<cv::Scalar> label_colors;
    cv::hconcat(colors_top, colors_bottom, label_colors);
    std::vector<size_t> label_sides = assignColorsToSides(label_colors);

    cv::Mat3b canvas_top = img_top * 0.25f;
    cv::Mat3b canvas_bottom = img_bottom * 0.25f;

    std::vector<std::string> texts_top;
    for (int i = 0; i < 3*9; ++i)
    {
        texts_top.push_back(generateText(i, label_sides));
    }
    std::vector<std::string> texts_bottom;
    for (int i = 3*9; i < 6*9; ++i)
    {
        texts_bottom.push_back(generateText(i, label_sides));
    }

    drawLabelInfo(canvas_top, points_top, texts_top, cv::Scalar(255, 255, 255), 1.0);
    drawLabelInfo(canvas_bottom, points_bottom, texts_bottom, cv::Scalar(255, 255, 255), 1.0);

    cv::imshow("top", canvas_top);
    cv::imshow("bottom", canvas_bottom);

    cv::Mat3b canvas(cv::Size(25 * 3.1 * 6, 25 * 3), cv::Vec3b(0,0,0));

    for (int i = 0; i < 6*9; ++i)
    {
        int side = i / 9;
        int row = (i % 9) / 3;
        int col = i % 3;

        cv::Rect rect(cv::Point(25 * (side * 3.1 + col), 25 * row), cv::Size(25,25));
        cv::rectangle(canvas, rect, label_colors[i], cv::FILLED);
        cv::rectangle(canvas, rect, cv::Scalar(0,0,0), 1);
    }

    for (int i = 0; i < 6*9; ++i)
    {
        int side = i / 9;
        int row = (i % 9) / 3;
        int col = i % 3;

        cv::Point text_bl(25 * (side * 3.1 + col) + 2, 25 * row + 15);
        cv::putText(canvas, generateText(i, label_sides), text_bl,
            cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0,0,0));
    }
    cv::imshow("colors", canvas);

    const std::vector<size_t> kociemba_order = {
        18, 19, 20, 21, 22, 23, 24, 25, 26, // U
         9, 10, 11, 12, 13, 14, 15, 16, 17, // R
         0,  1,  2,  3,  4,  5,  6,  7,  8, // F
        51, 48, 45, 52, 49, 46, 53, 50, 47, // D
        35, 34, 33, 32, 31, 30, 29, 28, 27, // L
        44, 43, 42, 41, 40, 39, 38, 37, 36, // B
    };
    std::stringstream ss;
    for (size_t i : kociemba_order)
    {
        ss << side_names[label_sides[i]];
    }
    printf("Cube state: %s\n", ss.str().c_str());
    fflush(stdout);

    twophase::Search search;
    std::string solution = search.solution(ss.str(), 18, 15, false);
    printf("Solution: %s\n", solution.c_str());
    fflush(stdout);

    cv::Mat3b solution_img = drawMoveSequence(solution);
    cv::imshow("solution", solution_img);

    cv::waitKey();
    return 0;
}
Exemplo n.º 5
0
int _tmain(int argc, char *argv[], char *envp[]) {

	CvCapture *cv_cap = cvCaptureFromCAM(CV_CAP_ANY);
	if (!cv_cap) {
		printf("Could not open camera\n");
		cvWaitKey(0);
		return -1;
	}

	int cam_width = (int)cvGetCaptureProperty(cv_cap, CV_CAP_PROP_FRAME_WIDTH);
	int cam_height = (int)cvGetCaptureProperty(cv_cap, CV_CAP_PROP_FRAME_HEIGHT);
	CvSize cam_size = cvSize(cam_width, cam_height);

	Userdata userdata = getSessionUserdata(cam_size);

	cvNamedWindow(INPUT_WINDOW, 0);
	cvResizeWindow(INPUT_WINDOW, cam_width, cam_height);
	cvNamedWindow(OUTPUT_WINDOW, 0);
	cvResizeWindow(OUTPUT_WINDOW, cam_width, cam_height);

	cvSetMouseCallback(INPUT_WINDOW, mouseCallback, &userdata);

	setupWindows(&userdata);

	IplImage *input = userdata.input[0];
	IplImage *output = userdata.output[0];

	int use_cam = 1;
	int flip = 1;
	while ((userdata.key = cvWaitKey(userdata.timestep)) != 27) { // wait 50 ms (20 FPS) or for ESC key
		IplImage *cam = cvQueryFrame(cv_cap); // get frame
		if (!cam) {
			printf("no input\n");
			continue;
		}

		switch (userdata.key) {
		case ' ':
			use_cam = !use_cam;
			break;
		case 'F':
			flip = !flip;
			break;
		}

		if (!use_cam) {
			operateImage(&userdata);
		} else {
			cvCopy(cam, input, NULL);
			if (flip) {
				cvFlip(input, NULL, 1);
			}
			operateImage(&userdata);
		}
		//cvResizeWindow(INPUT_WINDOW, input->width, input->height);
		cvShowImage(INPUT_WINDOW, input);

		//cvResizeWindow(OUTPUT_WINDOW, output->width, output->height);
		cvShowImage(OUTPUT_WINDOW, output);
		cvResizeWindow(OUTPUT_WINDOW, cam_width / 2, cam_height / 2);
	}
	/* clean up */
	cvReleaseCapture(&cv_cap);

	freeSessionUserdata(&userdata);
	destroyWindows();

	cvDestroyWindow(INPUT_WINDOW);
	cvDestroyWindow(OUTPUT_WINDOW);

	return 0;
}