Skip to content

Commit

Permalink
tests: use gst on both sides of the connection
Browse files Browse the repository at this point in the history
This makes both sides save the image in exactly the same format, so it
can be compared byte-by-byte without parsing.

Previously imagemagick has chosen a bit different color depth.

And also, convert it to I420 format and back to RGB. The I420 format is
used as the QVC transfer format and it has a different color coverage
than RGB. By converting to I420 and back the captured screen can have
the same colors (bit-by-bit) as the QVC image.

Alternative would be to capture I420 and compare that directly, but it
would be less convenient for debugging, as it's a less common _image_
format.
  • Loading branch information
marmarek committed Mar 28, 2024
1 parent 8e04635 commit c556e6b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/qvctests/integ.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,17 @@ def capture_from_video(self, vm):
gst_command, passio_popen=True).communicate()[0]

def capture_from_screen(self, vm):
gst_command = (
'gst-launch-1.0 --quiet ximagesrc num-buffers=1 '
'! capsfilter caps=video/x-raw,format=BGRx,colorimetry=2:4:7:1 '
'! videoconvert '
'! video/x-raw,format=I420 '
'! videoconvert '
'! video/x-raw,format=RGB '
'! fdsink'
)
return vm.run(
'import -window root -depth 8 rgb:-', passio_popen=True)\
.communicate()[0]
gst_command, passio_popen=True).communicate()[0]

def compare_images(self, img1, img2):
"""Compare images (array of RGB pixels), return similarity factor -
Expand Down

0 comments on commit c556e6b

Please sign in to comment.