private void CaptureArea(CancellationToken token) { try { _selectionForm.Close(); _selectionForm = null; } catch { } _selectionForm = new AreaSelectionForm(); var result = _selectionForm.ShowDialog(); if (result == DialogResult.Cancel) { return; } if (result == DialogResult.OK) { Rectangle selected = _selectionForm.SelectedRectangle; if (selected.Width == 0 || selected.Height == 0) { return; } Image screenshot = ScreenCaptureHelper.CaptureScreens(); EditAndUploadIfChecked(screenshot, selected, token); } }
private ImageSource CapturePixel() { Point point = System.Windows.Forms.Cursor.Position; Console.WriteLine("X: " + point.X + "\t Y: " + point.Y); point.X -= _pixelWidth / 2; point.Y -= _pixelHeight / 2; var image = ScreenCaptureHelper.CaptureWindow(User32Helper.GetDesktopWindow(), point.X, point.Y, _pixelWidth, _pixelHeight); return(ScreenCaptureHelper.ConvertImageToImageSource(image)); }
public void SendNextScreenRecordView(TcpSocketSaeaSession session) { ThreadPool.QueueUserWorkItem((o) => { if (_screen_record_width == 0 || _screen_record_height == 0) { return; } Thread.Sleep(_screen_record_spantime); byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.C_MAIN_SCREEN_RECORD_IMG, ScreenCaptureHelper.CaptureNoCursorToBytes(_screen_record_width, _screen_record_height)); SendMessageToServer(data); }); }
private void SendCustomVideoTick(object sender, EventArgs e) { int width = 0; int height = 0; int size = 0; byte[] screen_datas = ScreenCaptureHelper.GetScreenCapture(out width, out height); size = width * height * 3; IntPtr unmanagedPointer = Marshal.AllocHGlobal(screen_datas.Length); Marshal.Copy(screen_datas, 0, unmanagedPointer, screen_datas.Length); NIMCustomVideoDataInfo info = new NIMCustomVideoDataInfo(); info.VideoSubType = Convert.ToInt32(NIMVideoSubType.kNIMVideoSubTypeRGB); NIM.DeviceAPI.CustomVideoData(0, unmanagedPointer, Convert.ToUInt32(size), (uint)width, (uint)height, info); Marshal.FreeHGlobal(unmanagedPointer); }
public void SendNextScreenView(TcpSocketSaeaSession session) { ThreadPool.QueueUserWorkItem(c => { var getframe = session.CompletedBuffer.GetMessageEntity <DesktopViewGetFramePack>(); if (getframe.Width == 0 || getframe.Height == 0 || getframe.TimeSpan == 0 || getframe.TimeSpan < 50) { return; } Thread.Sleep(getframe.TimeSpan); byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.C_MAIN_SCREENWALL_IMG, ScreenCaptureHelper.CaptureNoCursorToBytes(getframe.Width, getframe.Height)); SendMessageToServer(data); }); }
public void GetNewWords() { Bitmap imageFile; if (Program.UseCaptureScreenshot) { imageFile = new Bitmap(ScreenCaptureHelper.CaptureDesktop()); } else { imageFile = GetImageByFile(); } // imageFile = new Bitmap("../../../data/results.png"); List <string> newCommonWords = GetNewCommonWords(imageFile); NewWordHelper.SaveCommonWords(newCommonWords); List <string> newObscureWords = GetNewObscureWords(imageFile); NewWordHelper.SaveObscureWords(newObscureWords); }
public char[] RetrieveCharacters() { DateTime now = DateTime.Now; Bitmap imageFile; if (Program.UseCaptureScreenshot) { imageFile = new Bitmap(ScreenCaptureHelper.CaptureDesktop()); } else { imageFile = GetImageByFile(); } Bitmap roi = GetPlayingfield(imageFile); Bitmap[] constructGroups = ConstructGroups(roi); Bitmap[] defineBackground = SetThreshold(constructGroups); List <char> chars = new List <char>(); foreach (Bitmap bitmap in defineBackground) { chars.AddRange(RetrieveCharsByOcr(bitmap, Program.TessDataDir)); } var charArray = chars.ToArray(); double amountmiliseconds1 = (DateTime.Now - now).TotalMilliseconds; Console.WriteLine("Time retrieving chardata from image: " + amountmiliseconds1); return(charArray); }
private void CaptureScreen(CancellationToken token) { Image screenshot = ScreenCaptureHelper.CaptureScreens(); EditAndUploadIfChecked(screenshot, screenshot.GetBounds(), token); }