PyGame Saving Webcam,图像被拆分

时间:2015-09-20 03:26:36

标签: python pygame

我正在使用pygame捕获图像,而我似乎无法正确使用它。附上的是图像,正如您所看到的,图像在中间分开。

这是源代码:

    try {
        $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
        // set the PDO error mode to exception
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        $stmt = $conn->prepare("SELECT b.g_balance + a.rewards  as Sum FROM reward a, balance b WHERE a.user_id = :userid AND b.user_id = a.user_id");
         $userid = $_POST['userid'];
         $stmt->bindParam(':userid', $userid);
        $stmt->execute();
        while($row=$stmt->fetch()){
            echo $row['Sum'];
    }
}

    catch(PDOException $e)
    {
        echo "Error: " . $e->getMessage();
    }
    $conn = null;

Image I have a problem with

1 个答案:

答案 0 :(得分:0)

好的,所以我发现了一个我正在发布的工作,因为它可能在将来有用:

def saveImage(fname):
    pygame.camera.init()
    cam_list = pygame.camera.list_cameras() 
    cam = pygame.camera.Camera(cam_list[0])
    cam.start()
    ## the duplicate get_image():
    ## the first one gets the camera working,
    ## the second captures a clean image
    cam.get_image()
    cam.get_image()
    img = cam.get_image()
    pygame.image.save(img,fname)
    cam.stop()