예제 #1
0
        public ResultSrv <ServiceCallResultSrv <AIPlatformSrv <ImageProcessingAuthenticationContentSrv> > > ImageProcessingAuthentication()
        {
            try
            {
                var output = new ResultSrv <ServiceCallResultSrv <AIPlatformSrv <ImageProcessingAuthenticationContentSrv> > >();

                var internalServiceCallVo = InternalServiceCallVo.ConcreteBuilder
                                            .SetToken("")
                                            .SetScApiKey("")
                                            //.SetScVoucherHash()
                                            .Build();

                var imageProcessingAuthenticationVo = ImageProcessingAuthenticationVo.ConcreteBuilder
                                                      .SetServiceCallParameters(internalServiceCallVo)
                                                      .SetImage1("")
                                                      .SetImage2("")
                                                      .SetMode(ImageComparisonMode.Easy)
                                                      .Build();
                AIService.ImageProcessingAuthentication(imageProcessingAuthenticationVo, response => Listener.GetResult(response, out output));
                return(output);
            }
            catch (PodException podException)
            {
                Console.WriteLine(
                    $"-- {podException.Code}-an error has occured : {Environment.NewLine}{podException.Message}");
                throw;
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw;
            }
        }
예제 #2
0
        public ResultSrv <ServiceCallResultSrv <AIPlatformSrv <NLUTransferMoneyContentSrv> > > NLUTransferMoney()
        {
            try
            {
                var output = new ResultSrv <ServiceCallResultSrv <AIPlatformSrv <NLUTransferMoneyContentSrv> > >();

                var internalServiceCallVo = InternalServiceCallVo.ConcreteBuilder
                                            .SetToken("")
                                            .SetScApiKey("")
                                            //.SetScVoucherHash({Put your VoucherHash})
                                            .Build();

                var nLUVo = NLUVo.ConcreteBuilder
                            .SetServiceCallParameters(internalServiceCallVo)
                            .SetText("مبلغ 1 تومان از حساب 80000 به حساب 100000 واریز کن")
                            .Build();
                AIService.NLUTransferMoney(nLUVo, response => Listener.GetResult(response, out output));
                return(output);
            }
            catch (PodException podException)
            {
                Console.WriteLine(
                    $"-- {podException.Code}-an error has occured : {Environment.NewLine}{podException.Message}");
                throw;
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw;
            }
        }
예제 #3
0
        public ResultSrv <ServiceCallResultSrv <LicensePlateReaderConyentSrv> > LicensePlateReader()
        {
            try
            {
                var output = new ResultSrv <ServiceCallResultSrv <LicensePlateReaderConyentSrv> >();

                var internalServiceCallVo = InternalServiceCallVo.ConcreteBuilder
                                            .SetToken("")
                                            .SetScApiKey("")
                                            //.SetScVoucherHash({Put your VoucherHash})
                                            .Build();

                var licensePlateReaderVo = LicensePlateReaderVo.ConcreteBuilder
                                           .SetServiceCallParameters(internalServiceCallVo)
                                           .SetImage("")
                                           .SetIsCrop(false)
                                           .Build();
                AIService.LicensePlateReader(licensePlateReaderVo, response => Listener.GetResult(response, out output));
                return(output);
            }
            catch (PodException podException)
            {
                Console.WriteLine(
                    $"-- {podException.Code}-an error has occured : {Environment.NewLine}{podException.Message}");
                throw;
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw;
            }
        }
예제 #4
0
파일: App.xaml.cs 프로젝트: milk57618/Dear
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);

            this.InitializeComponent();

            //Create Database File
            if (!CheckFileExists("POS.sqlite").Result)
            {
                using (var db = new SQLiteConnection(DB_PATH))
                {
                    db.CreateTable <Categorys>();
                    db.CreateTable <Product>();
                    db.CreateTable <Member>();
                    db.CreateTable <Sale>();
                    db.CreateTable <MemberTime>();
                    db.CreateTable <SaleSearch>();
                    db.CreateTable <SaleHistory>();
                }
            }

            this.Suspending += OnSuspending;
            this.Resuming   += OnResuming;

            //Access Ai, Language is English
            var config = new AIConfiguration("6bcfd8fcf822482e935475852b97c02d",
                                             SupportedLanguage.English);

            AIService = AIService.CreateService(config);

            apiAi = new ApiAi(config);
            apiAi.DataService.PersistSessionId();
        }
예제 #5
0
        public ResultSrv <ServiceCallResultSrv <AIPlatformSrv <SpeechToTextContentSrv> > > SpeechToText()
        {
            try
            {
                var output = new ResultSrv <ServiceCallResultSrv <AIPlatformSrv <SpeechToTextContentSrv> > >();

                var internalServiceCallVo = InternalServiceCallVo.ConcreteBuilder
                                            .SetToken("")
                                            .SetScApiKey("")
                                            //.SetScVoucherHash()
                                            .Build();

                var speechToTextVo = SpeechToTextVo.ConcreteBuilder
                                     .SetServiceCallParameters(internalServiceCallVo)
                                     .SetLinkFile("")
                                     .Build();
                AIService.SpeechToText(speechToTextVo, response => Listener.GetResult(response, out output));
                return(output);
            }
            catch (PodException podException)
            {
                Console.WriteLine(
                    $"-- {podException.Code}-an error has occured : {Environment.NewLine}{podException.Message}");
                throw;
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw;
            }
        }
예제 #6
0
 public AccountController(UserService _userService, UserArticleService _userArticleService, TopicService _topicService, AIService _aiService)
 {
     userService        = _userService;
     userArticleService = _userArticleService;
     topicService       = _topicService;
     aiService          = _aiService;
 }
예제 #7
0
        public ResultSrv <ServiceCallResultSrv <AIPlatformSrv <NLUMobilePhoneChargingContentSrv> > > NLUMobilePhoneCharging()
        {
            try
            {
                var output = new ResultSrv <ServiceCallResultSrv <AIPlatformSrv <NLUMobilePhoneChargingContentSrv> > >();

                var internalServiceCallVo = InternalServiceCallVo.ConcreteBuilder
                                            .SetToken("")
                                            .SetScApiKey("")
                                            //.SetScVoucherHash({Put your VoucherHash})
                                            .Build();

                var nLUVo = NLUVo.ConcreteBuilder
                            .SetServiceCallParameters(internalServiceCallVo)
                            .SetText("شماره موبایل 456456 را به مبلغ 1 تومان شارژ کن")
                            .Build();
                AIService.NLUMobilePhoneCharging(nLUVo, response => Listener.GetResult(response, out output));
                return(output);
            }
            catch (PodException podException)
            {
                Console.WriteLine(
                    $"-- {podException.Code}-an error has occured : {Environment.NewLine}{podException.Message}");
                throw;
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw;
            }
        }
예제 #8
0
파일: GameAuto.cs 프로젝트: topshadow/wings
        private static void playTask(int hwnd)
        {
            var rectangle = new Rectangle(810, 184, 168, 86);
            var bitmap    = Capture.CaptureWindowRectangle((IntPtr)hwnd, rectangle);

            System.IO.MemoryStream ms = new MemoryStream();
            bitmap.Save(ms, ImageFormat.Png);
            bitmap.Save("test.png");
            byte[] byteImage = ms.ToArray();
            var    base64    = Convert.ToBase64String(byteImage);
            var    text      = AIService.commonOcr(base64);
            var    taskText  = text.GetValues()["itemstring"];

            Console.WriteLine("task-title:" + taskText);
            if (taskText.Contains("20级"))
            {
                Click((IntPtr)hwnd, 856, 324);
                Console.WriteLine("已经满了16级,进行第二个任务");
            }
            else
            {
                Click((IntPtr)hwnd, 1000, 240);
                Console.WriteLine("OK, test event is fired at: " + DateTime.Now.ToString());
            }
            foreach (var key in text.GetValues().Keys)
            {
                Console.WriteLine("key:" + key);
            }
        }
예제 #9
0
        public MainWindow()
        {
            InitializeComponent();
            _startGameService = new StartGameService();
            _logicService     = new LogicService(_startGameService.TableDominoCollection,
                                                 _startGameService.MyDominosCollection, _startGameService.BankService);

            _startGameService.MyDominosCollection.Dominos.ForEach(d =>
            {
                d.ImageResource = $"Images/_{d.First}v{d.Second}_.png";
            });
            MyHandListView.ItemsSource = _startGameService.MyDominosCollection.Dominos;
            var startDomino = _startGameService.TableDominoCollection.Dominos.First();

            ////////////////////
            TopTableListView.ItemsSource   = _startGameService.TableDominoCollection.TopDominos;
            LeftTableListView.ItemsSource  = _startGameService.TableDominoCollection.LeftDominos;
            RightTableListView.ItemsSource = _startGameService.TableDominoCollection.RightDominos;
            BotTableListView.ItemsSource   = _startGameService.TableDominoCollection.BottomDominos;
            ////////////////////
            OpponentHandListView.ItemsSource = _startGameService.OpponentDominosCollection.Dominos;
            BankListView.ItemsSource         = _startGameService.AllDominos;

            _aIService = new AIService(new LogicService(_startGameService.TableDominoCollection,
                                                        _startGameService.OpponentDominosCollection, _startGameService.BankService));
            _aIService.AiTurnFinished += AiService_AiTurnFinished;

            RefreshAllItemSources();
        }
예제 #10
0
        public void GetFactsAndParseTest()
        {
            var articleText = "Взыскать с индивидуального предпринимателя Иванова Костантипа Петровича дата рождения 10 января 1970 года, проживающего по адресу город Санкт-Петербург, ул. Крузенштерна, дом 5 8 000 (восемь тысяч) рублей 00 копеей госпошлины в пользу бюджета РФ ООО Рога и копыта";

            var result = AIService.GetFacts(articleText);

            Console.WriteLine(result);
        }
        private async Task RunLadder(AIService aiService, Race myRace, int gamePort, int startPort)
        {
            await Connect(gamePort);

            var playerId = await JoinGameLadder(myRace, startPort);

            await Run(aiService, playerId);
            await RequestLeaveGame();
        }
        private async Task Run(AIService aiService, uint playerId)
        {
            var gameInfoReq = new Request();

            gameInfoReq.GameInfo = new RequestGameInfo();

            var gameInfoResponse = await proxy.SendRequest(gameInfoReq);

            var dataReq = new Request();

            dataReq.Data            = new RequestData();
            dataReq.Data.UnitTypeId = true;
            dataReq.Data.AbilityId  = true;
            dataReq.Data.BuffId     = true;
            dataReq.Data.EffectId   = true;
            dataReq.Data.UpgradeId  = true;

            var dataResponse = await proxy.SendRequest(dataReq);

            Controller.gameInfo = gameInfoResponse.GameInfo;
            Controller.gameData = dataResponse.Data;

            if (Controller.gameInfo == null)
            {
                File.WriteAllText(@"D:\GitProjects\SC2-CSharpe-Starterkit\gameInfoResponse.json", JsonConvert.SerializeObject(gameInfoResponse));
            }

            while (true)
            {
                var observationRequest = new Request();
                observationRequest.Observation = new RequestObservation();
                var response = await proxy.SendRequest(observationRequest);

                var observation = response.Observation;

                if (response.Status == Status.Ended || response.Status == Status.Quit)
                {
                    break;
                }

                Controller.obs = observation;
                var actions = aiService.Frame();

                var actionRequest = new Request();
                actionRequest.Action = new RequestAction();
                actionRequest.Action.Actions.AddRange(actions);
                if (actionRequest.Action.Actions.Count > 0)
                {
                    await proxy.SendRequest(actionRequest);
                }

                var stepRequest = new Request();
                stepRequest.Step       = new RequestStep();
                stepRequest.Step.Count = stepSize;
                await proxy.SendRequest(stepRequest);
            }
        }
예제 #13
0
        public AIServiceButtler(Activity mainActivity)
        {
            _config       = new AIConfiguration("<API-KEY Dialogflow>", SupportedLanguage.German);
            _aiService    = AIService.CreateService(Forms.Context, _config, RecognitionEngine.System);
            _mainActivity = mainActivity;

            _aiService.OnResult += _aiService_OnResult;
            _aiService.OnError  += _aiService_OnError;

            // SubscribeSpeechPopUpViewModel();
            SubscribeForStart();
            SubscribeCancelRequest();
        }
예제 #14
0
        public async Task InstallVCD()
        {
            try
            {
                StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///VoiceCommand.xml"));

                await AIService.InstallVoiceCommands(file);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
예제 #15
0
파일: App.xaml.cs 프로젝트: milk57618/Dear
        private void OnSuspending(object sender, SuspendingEventArgs e)
        {
            Debug.WriteLine("OnSuspending");

            var deferral = e.SuspendingOperation.GetDeferral();

            if (AIService != null)
            {
                AIService.Dispose();
                AIService = null;
            }
            deferral.Complete();
        }
예제 #16
0
 public ViewResult Index(Flat flat)
 {
     if (ModelState.IsValid)
     {
         var aiservice = new AIService(flat);
         flat.IsGoodOfert = aiservice.BuyOrNot();
         return(View("Result", flat));
     }
     else
     {
         ViewBag.isCheck = true;
         return(View());
     }
 }
예제 #17
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);

            InitializeComponent();
            Suspending += OnSuspending;
            Resuming   += OnResuming;

            var config = new AIConfiguration("929fcea94980486ea6837539e57bb34a",
                                             SupportedLanguage.English);

            AIService = AIService.CreateService(config);
        }
예제 #18
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);

            InitializeComponent();
            Suspending += OnSuspending;
            Resuming   += OnResuming;

            var config = new AIConfiguration("cb9693af-85ce-4fbf-844a-5563722fc27f",
                                             "40048a5740a1455c9737342154e86946",
                                             SupportedLanguage.English);

            AIService = AIService.CreateService(config);
        }
예제 #19
0
        public object commonOCR()
        {
            var gameProcesses = Finder.findGameProcesses("梦幻西游");
            var hwnd          = gameProcesses[0]?.hwnd;
            var rectangle     = new Rectangle(810, 184, 168, 86);
            var bitmap        = Capture.CaptureWindowRectangle((IntPtr)hwnd, rectangle);

            System.IO.MemoryStream ms = new MemoryStream();
            bitmap.Save(ms, ImageFormat.Png);
            bitmap.Save("test.png");
            byte[] byteImage = ms.ToArray();
            var    base64    = Convert.ToBase64String(byteImage);
            var    text      = AIService.commonOcr(base64);

            Console.WriteLine(text);
            return(text);
        }
예제 #20
0
        // GET: Petition
        public ActionResult Index(int id = 2860)
        {
            Article article = DataSource.Articles.FirstOrDefault(r => r.number == id);

            ViewBag.Text = article.description;
            Dictionary <string, SpanInfo[]> aiFacts = new Dictionary <string, SpanInfo[]>();

            try
            {
                aiFacts = AIService.GetFacts(article.description);

                ViewBag.Facts = aiFacts;
                ViewBag.Text  = article.description;

                var desc = article.description;
                var i    = 0;
                foreach (var fact in aiFacts)
                {
                    foreach (SpanInfo spanInfo in fact.Value)
                    {
                        var oldValue = article.description.Substring(
                            spanInfo.span[0], spanInfo.span[1] - spanInfo.span[0]);

                        desc = desc.Replace(
                            oldValue,
                            "<span title =\"" + fact.Key + " ?\" >" + oldValue

                            + "</span >");

                        i = spanInfo.span[1];
                    }
                }

                if (!string.IsNullOrEmpty(desc))
                {
                    ViewBag.Text = desc;
                }
            }
            catch (Exception e)
            {
            }


            return(View("Article", article));
        }
        public async Task RunSinglePlayer(AIService aiService, string map, Race myRace, Race opponentRace,
                                          Difficulty opponentDifficulty)
        {
            var port = 5678;

            Logger.Info("Starting SinglePlayer Instance");
            StartSC2Instance(port);
            Logger.Info("Connecting to port: {0}", port);
            await Connect(port);

            Logger.Info("Creating game");
            await CreateGame(map, opponentRace, opponentDifficulty);

            Logger.Info("Joining game");
            var playerId = await JoinGame(myRace);

            await Run(aiService, playerId);
        }
예제 #22
0
        public override void ViewDidLoad()
        {
            try
            {
                aiConfig = new AIConfiguration("135f1908-3d38-4954-83f4-d128948708b2",
                                               "a8f248a646ad49d3aa8d5f3ee017009a",
                                               SupportedLanguage.PortugueseBrazil);

                aiService = AIService.CreateService(aiConfig);

                this.StartListening();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            base.ViewDidLoad();
        }
        void SelectLanguageSpinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            var selectedLanguage = languages[e.Position];

            var lang   = SupportedLanguage.FromLanguageTag(selectedLanguage.LanguageCode);
            var config = new AIConfiguration("62f2522a-7404-4c28-b9ac-097ca5d8b32d",
                                             selectedLanguage.AccessToken, lang);

            if (aiService != null)
            {
                aiService.Cancel();
            }

            aiService = new SpeaktoitRecognitionService(this, config);

            aiService.OnResult          += AiService_OnResult;
            aiService.OnError           += AiService_OnError;
            aiService.ListeningStarted  += AiService_ListeningStarted;
            aiService.ListeningFinished += AiService_ListeningFinished;
            aiService.AudioLevelChanged += AiService_AudioLevelChanged;
        }
        private void InitializeService(LanguageConfig conf)
        {
            var lang   = SupportedLanguage.FromLanguageTag(conf.LanguageCode);
            var config = new AIConfiguration(conf.AccessToken, lang);

            //TODO: Option for verbose logging. Remove this line in production.
            config.DebugLog = true;

            if (aiService != null)
            {
                aiService.Cancel();
            }

            aiService = AIService.CreateService(config);

            aiService.OnResult          += AiService_OnResult;
            aiService.OnError           += AiService_OnError;
            aiService.ListeningStarted  += AiService_ListeningStarted;
            aiService.ListeningFinished += AiService_ListeningFinished;
            aiService.AudioLevelChanged += AiService_AudioLevelChanged;
        }
        private void InitializeService(LanguageConfig conf)
        {
            var lang   = SupportedLanguage.FromLanguageTag(conf.LanguageCode);
            var config = new AIConfiguration("62f2522a-7404-4c28-b9ac-097ca5d8b32d",
                                             conf.AccessToken, lang);

            config.JsonProcessingWithoutDynamicCode = true;
            config.DebugLog = true;

            if (aiService != null)
            {
                aiService.Cancel();
            }

            aiService = new SpeaktoitRecognitionService(config);

            aiService.OnResult          += AiService_OnResult;
            aiService.OnError           += AiService_OnError;
            aiService.ListeningStarted  += AiService_ListeningStarted;
            aiService.ListeningFinished += AiService_ListeningFinished;
            aiService.AudioLevelChanged += AiService_AudioLevelChanged;
        }
예제 #26
0
        public void AiServiceTestSuggestNegativeFlat()
        {
            var flat = new Flat()
            {
                KindOfOperation    = "W",
                KindOfSpace        = "M",
                RoomsAmount        = 5,
                LocationRating     = 4,
                Size               = 100,
                Price              = 13440,
                Standard           = 1,
                Floor              = 8,
                City               = "Bydgoszcz",
                UserRoomsAmount    = 4,
                UserPrice          = 6720,
                UserStandard       = 2,
                UserLocationRating = 3
            };
            var     aiservice = new AIService(flat);
            Boolean result    = aiservice.BuyOrNot();

            Assert.AreEqual(false, result);
        }
예제 #27
0
        public void AiServiceTestSuggestPositiveFlat()
        {
            var flat = new Flat()
            {
                KindOfOperation    = "K",
                KindOfSpace        = "M",
                RoomsAmount        = 4,
                LocationRating     = 5,
                Size               = 88,
                Price              = 473088,
                Standard           = 5,
                Floor              = 3,
                City               = "Poznañ",
                UserRoomsAmount    = 2,
                UserPrice          = 532224,
                UserStandard       = 1,
                UserLocationRating = 0
            };
            var     aiservice = new AIService(flat);
            Boolean result    = aiservice.BuyOrNot();

            Assert.AreEqual(true, result);
        }
예제 #28
0
        void SelectLanguageSpinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            var selectedLanguage = languages[e.Position];

            var lang   = SupportedLanguage.FromLanguageTag(selectedLanguage.LanguageCode);
            var config = new AIConfiguration("62f2522a-7404-4c28-b9ac-097ca5d8b32d",
                                             selectedLanguage.AccessToken, lang);

            //TODO: Option for verbose logging. Remove this line in production.
            config.DebugLog = true;

            if (aiService != null)
            {
                aiService.Cancel();
            }

            aiService = AIService.CreateService(this, config, RecognitionEngine.ApiAi);

            aiService.OnResult          += AiService_OnResult;
            aiService.OnError           += AiService_OnError;
            aiService.ListeningStarted  += AiService_ListeningStarted;
            aiService.ListeningFinished += AiService_ListeningFinished;
            aiService.AudioLevelChanged += AiService_AudioLevelChanged;
        }
        public async Task RunLadder(AIService aiService, Race myRace, string[] args)
        {
            var commandLineArgs = new CLArgs(args);

            await RunLadder(aiService, myRace, commandLineArgs.GamePort, commandLineArgs.StartPort);
        }
예제 #30
0
 public HomeController(UserService _userService, TopicService _topicService, AIService _aiService)
 {
     userService  = _userService;
     topicService = _topicService;
     aiService    = _aiService;
 }