接下来我们开始优化画面
首先我改了换行位置,原本是463才换行,差不多一行重复出现8个重复画面。我把463/8得到58。
在x>=58时换行。
from pylab import *
from rtlsdr import *
import cv2
sdr = RtlSdr()
# configure device
sdr.sample_rate = 1.951047e6
sdr.center_freq = 395.991e6
sdr.gain = 60
# init for opencv
x = 0
y = 0
img=np.zeros((600,600,1), np.uint8)
while True:
samples = sdr.read_samples(1024*100) #type(sample) is numpy.complex128
for sample in samples:
mag = np.sqrt( sample.imag * sample.imag + sample.real * sample.real)
value = mag * 255 * 10
img[y, x] = value
x = x + 1
if (x >= 58):
x = 0
y = y + 1
if (y >= 500):
y = 0
cv2.imshow("HDMI", img)
if(cv2.waitKey(10)==27):
break
sdr.close()
可以看到只剩一个画面了,但是画面宽度变窄,显得变形了。
这时候我再对每行的像素点插值,大概每个像素点重复往右画10遍,就可以得到如下效果:
可以看出现在画面放大了,基本上显示界面就对应了1个屏幕的泄漏画面。
行差值的代码如下:
from pylab import *
from rtlsdr import *
import cv2
sdr = RtlSdr()
# configure device
sdr.sample_rate = 1.951047e6
sdr.center_freq = 395.991e6
sdr.gain = 60
# init for opencv
x = 0
y = 0
img=np.zeros((600,600,1), np.uint8)
while True:
samples = sdr.read_samples(1024*100) #type(sample) is numpy.complex128
for sample in samples:
mag = np.sqrt( sample.imag * sample.imag + sample.real * sample.real)
value = mag * 255 * 10
img[y, x] = value
img[y, x + 1] = value
img[y, x + 2] = value
img[y, x + 3] = value
img[y, x + 4] = value
img[y, x + 5] = value
img[y, x + 6] = value
img[y, x + 7] = value
img[y, x + 8] = value
img[y, x + 9] = value
x = x + 10
if (x >= 580):
x = 0
y = y + 1
if (y >= 500):
y = 0
cv2.imshow("HDMI", img)
if(cv2.waitKey(10)==27):
break
sdr.close()
但是从画面看出来,整个屏幕还是斜的,本来白色矩形在我泄漏屏幕上应该垂直,但是现在是从右上往左下角倾斜的。
这个问题也可以解决,需要把每一行的数据单独存下来,然后上一行多出来的数据拼到下一行开头,或者从下一行开头取数据拼给上一行结尾。
本次实验泄漏画面是这样的,留作参考: