sn4k3 / UVtools

MSLA/DLP, file analysis, calibration, repair, conversion and manipulation
GNU Affero General Public License v3.0
1.19k stars 103 forks source link

[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 #919

Open Drynwhyl opened 2 weeks ago

Drynwhyl commented 2 weeks ago

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

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.<>cDisplayClass149_0.b0(Int64 layerIndex) in UVtools.Core\Operations\OperationPixelArithmetic.cs:line 924 at System.Threading.Tasks.Parallel.<>cDisplayClass20_0`1.b1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) --- End of stack trace from previous location --- at System.Threading.Tasks.Parallel.<>c__DisplayClass20_0`1.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

github-actions[bot] commented 2 weeks ago

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! 🙌

sn4k3 commented 2 weeks ago

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?

Drynwhyl commented 2 weeks ago

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

sn4k3 commented 2 weeks ago

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