Example #1
0
    def test_rotation(self):
        self.dev.keyevent("HOME")
        time.sleep(1)
        frame_vertical = self.minicap.get_frame_from_stream()
        frame_vertical = string_2_img(frame_vertical)
        self.dev.start_app(PKG)
        time.sleep(3)
        frame_horizontal = self.minicap.get_frame_from_stream()
        frame_horizontal = string_2_img(frame_horizontal)

        self.assertEqual(frame_vertical.shape[0], frame_horizontal.shape[1])
        self.assertEqual(frame_vertical.shape[1], frame_horizontal.shape[0])
Example #2
0
 def test_set_projection(self):
     # 目前暂时只支持minicap设置projection参数
     if self.dev.cap_method == "MINICAP":
         self.dev.keyevent("HOME")
         default_height = 800
         height = self.dev.display_info.get("height")
         width = self.dev.display_info.get("width")
         scale_factor = min(default_height, height) / height
         projection = (scale_factor * width, scale_factor * height)
         screen = string_2_img(self.dev.screen_proxy.get_frame(projection=projection))
         self.assertEqual(screen.shape[0], default_height)
Example #3
0
    def test_projection(self):
        """
        先按home键回到桌面,确保当前是竖屏
        然后设置高度为800,大部分手机竖屏高度都大于这个数值,计算出对应的projection参数
        最后验证截出来的图是否高度等于800
        Returns:

        """
        self.dev.keyevent("HOME")
        default_height = 800
        height = self.dev.display_info.get("height")
        width = self.dev.display_info.get("width")
        scale_factor = min(default_height, height) / height
        projection = (scale_factor * width, scale_factor * height)
        screen = string_2_img(self.minicap.get_frame(projection=projection))
        self.assertEqual(screen.shape[0], default_height)

        self.minicap.projection = projection
        screen_stream = self.minicap.get_frame_from_stream()
        screen2 = string_2_img(screen_stream)
        self.assertEqual(screen2.shape[0], default_height)
Example #4
0
 def test_0_get_frame(self):
     frame = self.javacap.get_frame_from_stream()
     frame = string_2_img(frame)
     self.assertIsInstance(frame, ndarray)
Example #5
0
 def test_get_frame(self):
     frame = self.minicap.get_frame()
     frame = string_2_img(frame)
     self.assertIsInstance(frame, ndarray)
Example #6
0
def api_ocr():
    img = request.form["image"]
    img = base64.b64decode(img)
    image = string_2_img(img)
    res = detect(image)
    return jsonify(res)