test_imgproc.jl 659 B

12345678910111213141516171819202122232425262728
  1. # Create a random image
  2. img = rand(UInt8 , 3, 500, 500)
  3. # Test input as AbstractArray and cvtColor
  4. img_gray = OpenCV.cvtColor(img, OpenCV.COLOR_RGB2GRAY)
  5. @test size(img_gray, 1) == 1 && size(img_gray, 2) == size(img, 2) && size(img_gray, 3) == size(img, 3)
  6. # Exception test
  7. try
  8. # This should throw an error
  9. OpenCV.cvtColor(img_gray, OpenCV.COLOR_RGB2GRAY)
  10. exit(1)
  11. catch
  12. # Error caught so we can continue
  13. end
  14. ve = view(img, :,200:300, 200:300)
  15. # Auto-conversion from-to OpenCV types
  16. ve_gray = OpenCV.cvtColor(ve, OpenCV.COLOR_RGB2GRAY)
  17. # Shape check
  18. @test size(ve_gray)[1] == 1 && size(img_gray)[1] == 1
  19. print("imgproc test passed\n")