Code Monkey home page Code Monkey logo

Comments (4)

waveform80 avatar waveform80 commented on May 28, 2024

That's weird - raw capture over the video port is included in the test suite, and passes (more or less) happily (there's some issue with 100x100 captures that I don't understand yet). Unfortunately, my camera's currently busy chewing through yet another test for #40 (which is unsurprisingly taking some time to debug and fix - given the random nature of it showing up). Could you possibly test your code without the resizer? Something like the following:

from __future__ import division

import picamera
import cv2
import numpy as np
import io
import time

class PiCam:

    def __init__(self):
        self.cam = picamera.PiCamera()
        self.cam.resolution = (320, 240)

    def read(self):
        stream = open('image.data', 'wb')
        self.cam.capture(stream, 'bgra', use_video_port=True)
        stream.seek(0)
        image = np.fromfile(stream, dtype = np.uint8)
        return image

cam = PiCam()
cv2.namedWindow("Camera Image", cv2.WINDOW_AUTOSIZE)
while True:
    cv2.imshow("Camera Image", cam.read())
    cv2.waitKey(1)
    return

In theory it shouldn't make any difference as the raw encoder was changed in 1.0 to use the resizer to handle the conversion from YUV to RGBA/BGRA/etc. (so that we don't have to manipulate the camera's own ports and break video recording, and because the video-splitter doesn't seem to like doing the conversion itself). In other words, all raw captures invoke the resizer but if no resize resolution is given, the resizer is set to the same resolution as the camera itself.

Still, the test suite doesn't actually include a test for raw captures over the video port including a resizer with a different resolution to the camera, so I'm wondering if that's the cause.

from picamera.

soren121 avatar soren121 commented on May 28, 2024

That seems to work. The size of the output stream is correct, according to your RGB recipe math (320 * 240 * 4=307200.) Getting OpenCV to read it is another story. Thanks.

from picamera.

waveform80 avatar waveform80 commented on May 28, 2024

Glad you got something working in the end - I'll try and find some time to look into this, but I doubt it'll be in time to make the release I'm planning for later today

from picamera.

waveform80 avatar waveform80 commented on May 28, 2024

Doh! Found the cause of this issue - a stupid error on my part. It's a trivial fix so it'll make it into tonight's release after all. Amended the title as the bug would actually cause any raw capture with a resize parameter (set to something other than the parent's resolution) to fail.

from picamera.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.