Пример #1
0
        private void StartCalibration_Click(object sender, RoutedEventArgs e)
        {
            //カメラプレビューの停止
            timerToPreview.Stop();

            //コントロールの切り替え
            InitializeGrid.Visibility = System.Windows.Visibility.Hidden;

            //チェスボード投影
            if (!IsMaximized)
            {
                bitmap = new WriteableBitmap((int)ImageWidthStandard, (int)ImageHeightStandard, 92, 92, PixelFormats.Gray8, null);
            }
            else
            {
                bitmap = new WriteableBitmap((int)mainGrid.ActualWidth, (int)mainGrid.ActualHeight, 92, 92, PixelFormats.Gray8, null);
            }
            TSUtil.CopyImageToBitmap(bitmap, calibrator.ChessBoardMat);
            SetBitmapToImage(PreviewImage, bitmap);

            //キャリブレーションテストの初期化
            calibratingCount = 0;

            //キャリブレーションの実行
            timerToCalibrate          = new DispatcherTimer();
            timerToCalibrate.Tick    += (s, ea) => CalibrateCameraInputLoop(s, ea);
            timerToCalibrate.Interval = TimeSpan.FromMilliseconds(1);
            timerToCalibrate.Start();
        }
Пример #2
0
        public void ConvertToIdsTest()
        {
            List <int> ids_list = new List <int>();

            {
                ids_list.Add(100);
                ids_list.Add(200);
                ids_list.Add(300);
            }

            int[] ids_array = { 100, 200, 300 };

            List <Model> models = new List <Model>();

            for (int i = 1; i <= 3; i++)
            {
                Model model = new Model();
                model.Id = i * 100;
                models.Add(model);
            }

            string expected     = "100,200,300";
            string actual_list  = TSUtil.ConvertToIds(ids_list);
            string actual_array = TSUtil.ConvertToIds(ids_array);

            Assert.AreEqual(expected, actual_list);
            Assert.AreEqual(expected, actual_array);
        }
Пример #3
0
 private void PreviewCameraInputLoop(object s, EventArgs e)
 {
     using (Mat mat = new Mat())
     {
         vc.Retrieve(mat, CameraChannels.Zero);
         TSUtil.CopyImageToBitmap(bitmap, mat);
     }
     SetBitmapToImage(PreviewImage, bitmap);
 }
Пример #4
0
 private void DebugImShow(Mat imgCap, Mat imgMat)
 {
     Cv2.ImShow("Camera Input", imgCap);
     Cv2.ImShow("EnterButton Current Image", TSUtil.ExtractROI(imgMat, EnterButton.ButtonPosition));
     Cv2.ImShow("ScrollBarhandle Current Image", TSUtil.ExtractROI(imgMat, ScrollBar.Thumb.ButtonPosition));
     Cv2.ImShow("EnterButton Reference Image", EnterButton.ReferenceImage);
     Cv2.ImShow("ScrollBarHandle Reference Image", ScrollBar.Thumb.ReferenceImage);
     imgMat.Line(new CvPoint((int)(ScrollBar.ScrollAreaRectangle.Left + ScrollBar.center_of_gravity), (int)ScrollBar.ScrollAreaRectangle.Top),
                 new CvPoint((int)(ScrollBar.ScrollAreaRectangle.Left + ScrollBar.center_of_gravity), (int)ScrollBar.ScrollAreaRectangle.Bottom),
                 new CvScalar(255, 0, 0), 3);
     imgMat.Rectangle(ScrollBar.Thumb.ButtonPosition, new CvScalar(0, 0, 255));
     imgMat.Rectangle(EnterButton.ButtonPosition, new CvScalar(0, 0, 255));
     Cv2.ImShow("Camera Input that is projective transformation", imgMat);
 }
        //implements Cloneable, Comparable

        /// <summary>
        /// Read return information in and store in a list. </summary>
        /// <param name="filename"> filename for data file to read </param>
        /// <exception cref="Exception"> if an error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static RTi.TS.DayTS readStateModFile(String filename) throws Exception
        public static DayTS readStateModFile(string filename)
        {
            string         routine   = "StateMod_DownstreamCall.readStateModFile";
            string         iline     = null;
            IList <string> vData     = new List <object>(4);
            int            linecount = 0;

            StreamReader @in = null;

            Message.printStatus(2, routine, "Reading downstream call file: " + filename);
            int      size = 0;
            int      errorCount = 0;
            int      year, month, day;
            double   adminNumber;
            DateTime date = new DateTime(DateTime.PRECISION_DAY);
            DayTS    ts   = null;

            try
            {
                @in = new StreamReader(IOUtil.getPathUsingWorkingDir(filename));
                bool headerRead = false;
                while (!string.ReferenceEquals((iline = @in.ReadLine()), null))
                {
                    ++linecount;
                    // check for comments
                    if (iline.StartsWith("#", StringComparison.Ordinal) || (iline.Trim().Length == 0))
                    {
                        // Special dynamic header comments written by software and blank lines - no need to keep
                        continue;
                    }
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "line: " + iline);
                    }
                    if (!headerRead)
                    {
                        // Read the header line and create the time series.
                        // This code copied from StateMod_TS.readTimeSeriesList()
                        string         format = "i5x1i4x5i5x1i4s5s5";
                        IList <object> v      = StringUtil.fixedRead(iline, format);
                        int            m1     = ((int?)v[0]).Value;
                        int            y1     = ((int?)v[1]).Value;
                        int            m2     = ((int?)v[2]).Value;
                        int            y2     = ((int?)v[3]).Value;
                        DateTime       date1Header;
                        date1Header = new DateTime(DateTime.PRECISION_DAY);
                        date1Header.setYear(y1);
                        date1Header.setMonth(m1);
                        date1Header.setDay(1);
                        DateTime date2Header;
                        date2Header = new DateTime(DateTime.PRECISION_DAY);
                        date2Header.setYear(y2);
                        date2Header.setMonth(m2);
                        date2Header.setDay(TimeUtil.numDaysInMonth(m2, y2));
                        string units     = ((string)v[4]).Trim();
                        string yeartypes = ((string)v[5]).Trim();
                        // TODO SAM 2011-01-02 Year type is not used since year month and day are all calendar

                        /*
                         * int yeartype = StateMod_DataSet.SM_CYR;
                         * // Year type is used in one place to initialize the year when
                         * // transferring data.  However, it is assumed that m1 is always correct for the year type.
                         * if ( yeartypes.equalsIgnoreCase("WYR") ) {
                         *      yeartype = StateMod_DataSet.SM_WYR;
                         * }
                         * else if ( yeartypes.equalsIgnoreCase("IYR") ) {
                         *      yeartype = StateMod_DataSet.SM_IYR;
                         * }
                         */
                        // year that are specified are used to set the period.
                        if (Message.isDebugOn)
                        {
                            Message.printDebug(1, routine, "Parsed m1=" + m1 + " y1=" + y1 + " m2=" + m2 + " y2=" + y2 + " units=\"" + units + "\" yeartype=\"" + yeartypes + "\"");
                        }
                        // Now create the time series
                        string tsidentString = "OprType23..DownstreamCall.Day";
                        ts = (DayTS)TSUtil.newTimeSeries(tsidentString, true);
                        ts.setDate1(date1Header);
                        ts.setDate1Original(date1Header);
                        ts.setDate2(date2Header);
                        ts.setDate2Original(date2Header);
                        ts.setDataUnits(units);
                        ts.setDataUnitsOriginal(units);
                        ts.allocateDataSpace();
                    }
                    else
                    {
                        // A time series data line
                        // Break the line using whitespace, while allowing for quoted strings...
                        try
                        {
                            vData = StringUtil.breakStringList(iline, " \t", StringUtil.DELIM_ALLOW_STRINGS | StringUtil.DELIM_SKIP_BLANKS);
                            size  = 0;
                            if (vData != null)
                            {
                                size = vData.Count;
                            }
                            if (size < 3)
                            {
                                Message.printStatus(2, routine, "Ignoring line " + linecount + " not enough data values.  Have " + size + " expecting 3");
                                ++errorCount;
                                continue;
                            }
                            // Uncomment if testing...
                            //Message.printStatus ( 2, routine, "" + v );

                            // Allocate new plan node and set the values
                            year        = int.Parse(vData[0].Trim());
                            month       = int.Parse(vData[1].Trim());
                            day         = int.Parse(vData[2].Trim());
                            adminNumber = double.Parse(vData[3].Trim());
                            date.setYear(year);
                            date.setMonth(month);
                            date.setDay(day);
                            ts.setDataValue(date, adminNumber);
                        }
                        catch (Exception e2)
                        {
                            Message.printWarning(3, routine, "Error reading line " + linecount + " \"" + iline + "\" (" + e2 + ") - skipping line.");
                            Message.printWarning(3, routine, e2);
                        }
                    }

                    // Set the data to not dirty because it was just initialized...

                    ts.setDirty(false);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, "Error reading line " + linecount + " \"" + iline + "\" uniquetempvar.");
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@in != null)
                {
                    @in.Close();
                }
            }
            if (errorCount > 0)
            {
                throw new Exception("There were " + errorCount + " errors processing the data - refer to log file.");
            }
            // Return the single time series.
            return(ts);
        }
	/// <summary>
	/// Display the time series. </summary>
	/// <param name="action"> Event action that initiated the display. </param>
	private void displayTSViewJFrame(string action)
	{
		string routine = "displayTSViewJFrame";

		// Initialize the display...

		PropList display_props = new PropList("ClimateStation");
		if (action.Equals(__BUTTON_GRAPH))
		{
			display_props.set("InitialView", "Graph");
		}
		else if (action.Equals(__BUTTON_TABLE))
		{
			display_props.set("InitialView", "Table");
		}
		else if (action.Equals(__BUTTON_SUMMARY))
		{
			display_props.set("InitialView", "Summary");
		}
		// display_props.set("HelpKey", "TSTool.ExportMenu");
		display_props.set("TotalWidth", "600");
		display_props.set("TotalHeight", "400");
		display_props.set("Title", "Demand");
		display_props.set("DisplayFont", "Courier");
		display_props.set("DisplaySize", "11");
		display_props.set("PrintFont", "Courier");
		display_props.set("PrintSize", "7");
		display_props.set("PageLength", "100");

		PropList props = new PropList("ClimateStation");

		IList<TS> tslist = new List<TS>();

		// Get the time series to display and set plot properties if graphing.
		// For now need to find in the lists because references to time series
		// are not implemented...

		IList<TS> v = null;
		TS ts = null;
		int sub = 0;
		int pos;
		StateCU_ClimateStation station = __stationsVector[__currentStationIndex];
		if (__precipitationCheckBox.isSelected())
		{
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<RTi.TS.TS> v0 = (java.util.List<RTi.TS.TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData();
			IList<TS> v0 = (IList<TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData();
			v = v0;
			pos = TSUtil.IndexOf(v, station.getID(), "Location", 1);
			if (pos >= 0)
			{
				ts = (TS)v[pos];
			}
			if (ts != null)
			{
				// Add a graph for precipitation...
				++sub;
				ts.setDataType("Precipitation");
				props.set("SubProduct " + sub + ".GraphType=Bar");
				props.set("SubProduct " + sub + ".SubTitleString=Monthly Precipitation");
				props.set("Data " + sub + ".1.TSID=" + ts.getIdentifierString());
				tslist.Add(ts);
			}
		}
		if (__temperatureCheckBox.isSelected())
		{
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<RTi.TS.TS> v0 = (java.util.List<RTi.TS.TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_TEMPERATURE_TS_MONTHLY_AVERAGE).getData();
			IList<TS> v0 = (IList<TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_TEMPERATURE_TS_MONTHLY_AVERAGE).getData();
			v = v0;
			pos = TSUtil.IndexOf(v, station.getID(), "Location", 1);
			if (pos >= 0)
			{
				ts = (TS)v[pos];
			}
			if (ts != null)
			{
				// Add a graph for temperature...
				++sub;
				ts.setDataType("Temperature");
				props.set("SubProduct " + sub + ".GraphType=Line");
				props.set("SubProduct " + sub + ".SubTitleString=Monthly Average Temperature");
				props.set("Data " + sub + ".1.TSID=" + ts.getIdentifierString());
				tslist.Add(ts);
			}
		}
		if (__frostDatesCheckBox.isSelected())
		{
			// REVISIT - no way to graph currently
		}

		// Display the time series...

		try
		{
			TSProduct tsproduct = new TSProduct(props, display_props);
			tsproduct.setTSList(tslist);
			new TSViewJFrame(tsproduct);
		}
		catch (Exception e)
		{
			Message.printWarning(1,routine,"Error displaying time series.");
			Message.printWarning(2, routine, e);
		}
	}
Пример #7
0
 public String GetUserIds()
 {
     return(TSUtil.ConvertToIds(Users));
 }