[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
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
- Go to "Tools" -> "Pixel Arithmethic"
- Make sure layer range is set to all layers
- Set Operator: Subtract with brightness
- Set Apply to: Model surface
- Set brightness: Use a pattern instead of fixed brightness
- Set Alternate pattern every "1" layers
- Set pattern to: 0 32 32 0
- Set alternate pattern to: 32 0 0 32
- Click "Pixel arithmetic" button to start operation
- Result: Error should occur
Files
No response
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! 🙌
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?
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
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
Cant repo, if you get this again and able to reproduce at 100% the times please reopen.