leng-yue / py-scrcpy-client

An easy to use python scrcpy client
https://leng-yue.github.io/py-scrcpy-client/
MIT License
308 stars 76 forks source link

Low text quality #7

Closed JustinDBruce closed 3 years ago

JustinDBruce commented 3 years ago

Is there a way to increase the quality of the screen? I am have trouble reading some of the text. Maybe increasing the resolution? How could I go about doing that?

Thank you

leng-yue commented 3 years ago

Please check Document.
When max_width is set to zero, scrcpy will use the full resolution of the android devices.

JustinDBruce commented 3 years ago

I am setting the max width to something beside 0, I've tried (1, 1920, 2560, and 3840). I also tried changing the bit rate to 16M, 32M, 64M, and 128M. I seems to have no effect though.

leng-yue commented 3 years ago

You can check the numpy nd.array, it's size should be equal to the resolution. By the way, can you add a code snippet? So that I can test on my devices.

JustinDBruce commented 3 years ago

I think I have found it. In core.py: def init( self, device: Optional[Union[AdbDevice, str]] = None, max_width: int = 2560, <--setting this has no effect on the screen size bitrate: int = 16000000, max_fps: int = 0, flip: bool = False, block_frame: bool = False, stay_awake: bool = False, lock_screen_orientation: int = const.LOCK_SCREEN_ORIENTATION_UNLOCKED, ): However, self.flip = flip self.max_width = int(1200) <--This will change the screen size self.bitrate = bitrate self.max_fps = max_fps self.block_frame = block_frame self.stay_awake = stay_awake self.lock_screen_orientation = lock_screen_orientation

leng-yue commented 3 years ago

I found that you set max_size to 1200 manually. Do your phone's screen resolution equals 1200*xxx?

JustinDBruce commented 3 years ago

No, I use a tablet. When I run scrcpy the Initial texture is 2560x1600. Using this I am getting something else though which is fine. I just needed to increase the size because the text was pixelated and its hard to read.

leng-yue commented 3 years ago

You should change your width to 2560. Could you upload a screenshot from your tablet and a screenshot from py-scrcpy?

JustinDBruce commented 3 years ago

TabletScreenShot scrcpyScreenShot

I am not able to set the width to 2560, it takes up more room then my screen has. The scrcpyScreenShot is from the default settings. Do you see what I mean about the pixilation?

leng-yue commented 3 years ago

I believe you can see the text clearly in 2560, is that correct? My suggestion is to add a factor to the window resize part to make the window smaller. https://github.com/leng-yue/py-scrcpy-client/blob/a8222520c09f968ad0449eba280a96e8bd95e29c/scrcpy_ui/main.py#L147

self.resize(self.client.resolution[0]*0.5, self.client.resolution[1]*0.5)  # 2560 to 1280

After modifying this, while it still consumes 2560 video from your tablet, it shows 1280 on your PC's screen.

JustinDBruce commented 3 years ago

Yes you are correct. I made the change you suggested, but no difference is seen. Still displaying at 2560. It was showing a float error so I casted to int(see below). That had no effect either.

        resize = int(self.client.resolution[0]*0.5)
        resize1 = int(self.client.resolution[1]*0.5)
        pix = QPixmap(image)
        self.ui.label.setPixmap(pix)
        self.resize(resize, resize1)

Also trying self.resize(1280, 800) has no effect

leng-yue commented 3 years ago

Sorry, I should use // 2 (floor divide) instead of * 0.5.

leng-yue commented 3 years ago

If it still doesn't work after casting, you can use OpenCV cv2.resize to resize the image, and the resolution should be smaller.

JustinDBruce commented 3 years ago

So I was able to go back to default setting and change this setting: main.py @click.option( "--max_width", default=800, <--Changed to zero show_default=True, help="Set max width of the window", )

Now the screen displays at 2560, but still won't resize with

self.resize(self.client.resolution[0]//2, self.client.resolution[1]//2)

Not too sure on how to use click is there a way to remove this option all together?

leng-yue commented 3 years ago

My idea is that you can cv2.resize the image to 1/2 before here https://github.com/leng-yue/py-scrcpy-client/blob/a8222520c09f968ad0449eba280a96e8bd95e29c/scrcpy_ui/main.py#L138 Then, you can use self.resize(self.client.resolution[0]//2, self.client.resolution[1]//2) It should fit your screen. Using self.resize independently doesn't work is probably caused by the QT's design, since QImage is larger than the window, the window must be resized to large enough to contain this QImage. So we need to make the original image smaller.

JustinDBruce commented 3 years ago

Thank you for everything! Closing the issue.