UVtools icon indicating copy to clipboard operation
UVtools copied to clipboard

[Bug] Pixel arithmetic results in error: Emgu.CV.Util.CvException: OpenCV: 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows

Open Drynwhyl opened this issue 1 year ago • 4 comments

System

UVtools v4.4.1 X64
Operative system: Microsoft Windows 10.0.19045 X64
Processor: AMD Ryzen 5 7600 6-Core Processor              
Processor cores: 12
Memory RAM: 10.42 / 27.62 GB
Runtime: win10-x64
Framework: .NET 6.0.33
AvaloniaUI: 11.1.3
OpenCV: 4.9.0

Path:       C:\Program Files\UVtools\
Executable: C:\Program Files\UVtools\UVtools.exe
Loaded file: The Rotten Base_10h06m_46ml_copy.pwma [Version: 516] [Class: PhotonWorkshopFile]

Printer and Slicer

  • Printer: Photon Mono 4K
  • Slicer: Lychee 6.2.0

Description of the bug

Following error occurs when I try to perform pixel arithmetic operation on multiple layers. It is not consistent, it may occur on different layers of the same file. If I'm lucky enough after 8-10 attempts it completes without error, but sometimes I just give up after 20+ tries: Emgu.CV.Util.CvException: OpenCV: 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows at Emgu.CV.CvInvoke.CvErrorHandler(Int32 status, IntPtr funcName, IntPtr errMsg, IntPtr fileName, Int32 line, IntPtr userData) at Emgu.CV.MatInvoke.cveMatCreateFromRect(IntPtr mat, Rectangle& roi) at UVtools.Core.Extensions.EmguExtensions.Roi(Mat mat, Rectangle roi, EmptyRoiBehaviour emptyRoiBehaviour) in UVtools.Core\Extensions\EmguExtensions.cs:line 944 at UVtools.Core.Operations.OperationPixelArithmetic.<>c__DisplayClass149_0.<ExecuteInternally>b__0(Int64 layerIndex) in UVtools.Core\Operations\OperationPixelArithmetic.cs:line 924 at System.Threading.Tasks.Parallel.<>c__DisplayClass20_01.<ForWorker64>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) --- End of stack trace from previous location --- at System.Threading.Tasks.Parallel.<>c__DisplayClass20_01.<ForWorker64>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) at System.Threading.Tasks.TaskReplicator.Replica.Execute()

How to reproduce

  1. Go to "Tools" -> "Pixel Arithmethic"
  2. Make sure layer range is set to all layers
  3. Set Operator: Subtract with brightness
  4. Set Apply to: Model surface
  5. Set brightness: Use a pattern instead of fixed brightness
  6. Set Alternate pattern every "1" layers
  7. Set pattern to: 0 32 32 0
  8. Set alternate pattern to: 32 0 0 32
  9. Click "Pixel arithmetic" button to start operation
  10. Result: Error should occur

Files

No response

Drynwhyl avatar Aug 25 '24 05:08 Drynwhyl

This is your first time submitting an issue with UVtools 🥳Please review your issue and ensure that the submit template was followed, the information is complete, and not related to any other open issue. It will be reviewed shortly. Debugging is very important and make the program better. Thanks for contributing and making the software better! 🙌

github-actions[bot] avatar Aug 25 '24 05:08 github-actions[bot]

This is the same as https://github.com/sn4k3/UVtools/issues/905 I also cannot reproduce using your workflow. Can you provide the file? Does it happen every time to you?

sn4k3 avatar Aug 25 '24 23:08 sn4k3

It happens almost every time with large file (2000-3000 layers). If it's something small (around 300-500 layers) it can work first try. Here is the file link: https://drive.google.com/file/d/1q6aH6RXziXLpUuh7nYFL_CXULw_LoCrW/view?usp=sharing

Drynwhyl avatar Aug 26 '24 11:08 Drynwhyl

Tested with your file and it works fine, I ran 5 times the operation without errors. Need to dig into this and see if I can spot the problem

sn4k3 avatar Aug 26 '24 18:08 sn4k3

Cant repo, if you get this again and able to reproduce at 100% the times please reopen.

sn4k3 avatar Dec 18 '24 02:12 sn4k3