Hỏi đáp
Chia sẻ kiến thức, cùng nhau phát triển
Mình viết một đoạn mã sử dụng click chuột chạy trong vòng 10 phút và lặp lại thao tác đó khoảng 100 lần. Đối với vòng 10 phút không xảy ra bất ký lỗi gì. Tuy nhiên khi chương trình chạy khoảng 1 tiếng đồng hồ tự động thoát. (6-7 lần lặp 10 phút). Mình không hiểu nguyên nhân, có phải do lỗi tràn bộ nhớ không? Vì mình thấy dung lượng chạy phần mềm càng lúc càng tăng. Mong các bạn giúp mình giải pháp khắc phục. (không phải lỗi X86 - Mình đã build X86).
Sau khi kiểm tra chạy lại thì kết quả chạy trả lại kết quả lỗi tại
var Point = KAutoHelper.ImageScanOpenCV.FindOutPoint(manhinh, anh);
if (Point != null)
{
KAutoHelper.ADBHelper.Tap(deviceID, Point.Value.X, Point.Value.Y);
chay = 11;
manhinh.Dispose();
Point = null;
if (IsStop)
break;
}
......
Và chương trình thông báo lỗi như sau:
emgu.cv.util.cvexception 'opencv u != 0'
Emgu.CV.Util.CvException
HResult=0x80131500
Message=OpenCV: u != 0
Source=Emgu.CV.World
StackTrace:
at Emgu.CV.CvInvoke.CvErrorHandler(Int32 status, IntPtr funcName, IntPtr errMsg, IntPtr fileName, Int32 line, IntPtr userData)
at Emgu.CV.CvInvoke.cveMatchTemplate(IntPtr image, IntPtr templ, IntPtr result, TemplateMatchingType method, IntPtr mask)
at Emgu.CV.CvInvoke.MatchTemplate(IInputArray image, IInputArray templ, IOutputArray result, TemplateMatchingType method, IInputArray mask)
at Emgu.CV.Image`2.MatchTemplate(Image`2 template, TemplateMatchingType method)
at KAutoHelper.ImageScanOpenCV.FindOutPoint(Bitmap mainBitmap, Bitmap subBitmap, Double percent)
at S1.MainWindow.Testanh(String deviceID, Bitmap anh) in C:\Users\Admin\source\repos\S1\S1\MainWindow.xaml.cs:line 635
at S1.MainWindow.qdao5() in C:\Users\Admin\source\repos\S1\S1\MainWindow.xaml.cs:line 1792
at S1.MainWindow.SQclick(Object sender, RoutedEventArgs e) in C:\Users\Admin\source\repos\S1\S1\MainWindow.xaml.cs:line 1147
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at S1.App.Main()
Theo mình nghĩ do bộ nhớ đã chiếm quá nhiều tài nguyên, còn nguyên nhân cụ thể thì mình không biết, có lẽ là liên quan đến kiến thức của môn kiến trúc máy tính, bạn nên tìm hiểu lại môn này để biết nguyên nhân cụ thể là gì nha! Chúc bạn thành công!