aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml
blob: 8733d4e0c181bb0c5553e561c66a9565428d975a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<Window x:Class="Tango.MachineStudio.Updater.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Tango.MachineStudio.Updater"
        mc:Ignorable="d"
        Title="Machine Studio Update" Height="400" Width="700" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" WindowStyle="None" ResizeMode="NoResize" Foreground="#202020">

    <Border BorderThickness="1" BorderBrush="#0288D1">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="60"/>
                <RowDefinition Height="156*"/>
            </Grid.RowDefinitions>

            <Grid Background="#0288D1">
                <Grid.Effect>
                    <DropShadowEffect BlurRadius="10" ShadowDepth="5" Direction="270" Opacity="0.5" />
                </Grid.Effect>

                <StackPanel Orientation="Horizontal" Margin="8" HorizontalAlignment="Center">
                    <Image Source="/Images/machine-trans.png" RenderOptions.BitmapScalingMode="Fant"></Image>
                    <TextBlock Foreground="White" VerticalAlignment="Center" Margin="10 0 0 0" FontSize="23">MACHINE STUDIO</TextBlock>
                </StackPanel>
            </Grid>

            <Grid Grid.Row="1">
                <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Image Source="/Images/update.png" Width="100" />
                    <TextBlock x:Name="txtStatus" Margin="0 20 0 0" FontSize="12" Text="Updating Machine Studio..." HorizontalAlignment="Center"></TextBlock>
                    <ProgressBar x:Name="prog" Margin="0 30 0 0" Width="500" Height="10" Maximum="100" Value="0" Foreground="#0288D1"></ProgressBar>
                </StackPanel>
            </Grid>
        </Grid>
    </Border>
</Window>
ht .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                           License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * The name of the copyright holders may not be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/

#include "opencv2/opencv_modules.hpp"
#include "opencv2/core.hpp"
#ifdef HAVE_OPENCV_DATASETS

#include "opencv2/datasets/track_vot.hpp"
#include <opencv2/core/utility.hpp>
#include <opencv2/tracking.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include "samples_utility.hpp"
#include <iostream>

using namespace std;
using namespace cv;
using namespace cv::datasets;

#define NUM_TEST_FRAMES 1000

static Mat image;
static bool paused;
static bool selectObjects = false;
static bool startSelection = false;
vector<Rect2d> boundingBoxes;
int targetsCnt = 0;
int targetsNum = 0;
Rect2d boundingBox;

static const char* keys =
{ "{@tracker_algorithm | | Tracker algorithm }"
"{@target_num     |1| Number of targets }"
"{@dataset_path     |true| Dataset path     }"
"{@dataset_id     |1| Dataset ID     }"
};

static void onMouse(int event, int x, int y, int, void*)
{
	if (!selectObjects)
	{
		switch (event)
		{
		case EVENT_LBUTTONDOWN:
			//set origin of the bounding box
			startSelection = true;
			boundingBox.x = x;
			boundingBox.y = y;
			boundingBox.width = boundingBox.height = 0;
			break;
		case EVENT_LBUTTONUP:
			//sei with and height of the bounding box
			boundingBox.width = std::abs(x - boundingBox.x);
			boundingBox.height = std::abs(y - boundingBox.y);
			boundingBoxes.push_back(boundingBox);
			targetsCnt++;
			if (targetsCnt == targetsNum)
			{
				paused = false;
				selectObjects = true;
			}
			startSelection = false;
			break;
		case EVENT_MOUSEMOVE:

			if (startSelection && !selectObjects)
			{
				//draw the bounding box
				Mat currentFrame;
				image.copyTo(currentFrame);
				for (int i = 0; i < (int)boundingBoxes.size(); i++)
					rectangle(currentFrame, boundingBoxes[i], Scalar(255, 0, 0), 2, 1);
				rectangle(currentFrame, Point((int)boundingBox.x, (int)boundingBox.y), Point(x, y), Scalar(255, 0, 0), 2, 1);
				imshow("Tracking API", currentFrame);
			}
			break;
		}
	}
}

static void help()
{
	cout << "\nThis example shows the functionality of \"Long-term optical tracking API\""
		"TLD dataset ID: 1~10, VOT2015 dataset ID: 1~60\n"
		"-- pause video [p] and draw a bounding boxes around the targets to start the tracker\n"
		"Example:\n"
		"./example_tracking_multiTracker_dataset<tracker_algorithm> <number_of_targets> <dataset_path> <dataset_id>\n"
		<< endl;

	cout << "\n\nHot keys: \n"
		"\tq - quit the program\n"
		"\tp - pause video\n";
}

int main(int argc, char *argv[])
{
	CommandLineParser parser(argc, argv, keys);
	string tracker_algorithm = parser.get<string>(0);
	targetsNum = parser.get<int>(1);
	string datasetRootPath = parser.get<string>(2);
	int datasetID = parser.get<int>(3);
	if (tracker_algorithm.empty() || datasetRootPath.empty() || targetsNum < 1)
	{
		help();
		return -1;
	}

	Mat frame;
	paused = false;
	namedWindow("Tracking API", 0);
	setMouseCallback("Tracking API", onMouse, 0);

	MultiTrackerTLD mt;
	//Init Dataset
	Ptr<TRACK_vot> dataset = TRACK_vot::create();
	dataset->load(datasetRootPath);
	dataset->initDataset(datasetID);

	//Read first frame
	dataset->getNextFrame(frame);
	frame.copyTo(image);
	for (int i = 0; i < (int)boundingBoxes.size(); i++)
		rectangle(image, boundingBoxes[i], Scalar(255, 0, 0), 2, 1);
	imshow("Tracking API", image);

	bool initialized = false;
	paused = true;
	int frameCounter = 0;

	//Time measurment
	int64 e3 = getTickCount();

	for (;;)
	{
		if (!paused)
		{
			//Time measurment
			int64 e1 = getTickCount();
			if (initialized){
				if (!dataset->getNextFrame(frame))
					break;
				frame.copyTo(image);
			}

			if (!initialized && selectObjects)
			{
				//Initialize the tracker and add targets
				for (int i = 0; i < (int)boundingBoxes.size(); i++)
				{
                    if (!mt.addTarget(frame, boundingBoxes[i], createTrackerByName(tracker_algorithm)))
					{
						cout << "Trackers Init Error!!!";
						return 0;
					}
					rectangle(frame, boundingBoxes[i], mt.colors[0], 2, 1);
				}
				initialized = true;
			}
			else if (initialized)
			{
				//Update all targets
				if (mt.update(frame))
				{
					for (int i = 0; i < mt.targetNum; i++)
					{
						rectangle(frame, mt.boundingBoxes[i], mt.colors[i], 2, 1);
					}
				}
			}
			imshow("Tracking API", frame);
			frameCounter++;
			//Time measurment
			int64 e2 = getTickCount();
			double t1 = (e2 - e1) / getTickFrequency();
			cout << frameCounter << "\tframe :  " << t1 * 1000.0 << "ms" << endl;
		}

		char c = (char)waitKey(2);
		if (c == 'q')
			break;
		if (c == 'p')
			paused = !paused;

		//waitKey(0);
	}

	//Time measurment
	int64 e4 = getTickCount();
	double t2 = (e4 - e3) / getTickFrequency();
	cout << "Average Time for Frame:  " << t2 * 1000.0 / frameCounter << "ms" << endl;
	cout << "Average FPS:  " << 1.0 / t2*frameCounter << endl;


	waitKey(0);

	return 0;
}

#else // ! HAVE_OPENCV_DATASETS
#include <opencv2/core.hpp>
int main() {
	CV_Error(cv::Error::StsNotImplemented , "this sample needs to be built with opencv_datasets !");
	return -1;
}
#endif // HAVE_OPENCV_DATASETS