What format does “adb screencap /sdcard/screenshot.raw” produce? (without “-p” flag)

后端 未结 3 1848
悲哀的现实
悲哀的现实 2021-02-09 05:54

I am looking to use adb screencap utility without the -p flag. I imagined output will be dumped in raw format, but doesn\'t look like it. My attempts o

3条回答
  •  你的背包
    2021-02-09 06:32

    To read adb screencap raw format in python:

    from PIL import Image
    Image.frombuffer('RGBA', (1920, 1080), raw[12:], 'raw', 'RGBX', 0, 1)
    

    The most important part is skipping the header, as mentioned in @Emmanuel's answer

    Note that (1920, 1080) are your device resolution which can be obtained with

    adb shell wm size
    

    Hopefully this will save someone 12 hours investigating why cv2.matchTemplate has different match on almost identical images.

提交回复
热议问题