Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with capture_continuous #311

Closed
weathernick opened this issue Aug 6, 2016 · 3 comments
Closed

Issue with capture_continuous #311

weathernick opened this issue Aug 6, 2016 · 3 comments
Assignees
Labels
Milestone

Comments

@weathernick
Copy link

I think I found a bug or a feature?

I run capture_continuous and have it pause for 6ish seconds. I just noticed when I upgraded to 1.12 that back to back images are the same. So for time 0sec I have an images, 6 seconds later I grab another image from capture_continuous and it turns out to be the same image. 6 seconds later I get a new image but it gets doubled on the next cycle. so instead of ABCDEFG I get AACCEEGG.

My code:
for i, filename in enumerate(camera.capture_continuous(nightpath+'/{timestamp:%H%M%S}.jpg', resize=resolution, burst=True, quality=quality)): sleep = nextpictime("night",filename) time.sleep(sleep)

I tried turning off burst and addjusting my sleep but same results. I reverted back to 1.10 which works fine for me and my four weather cameras.

Just figured I would let you know.

Thanks,

Nickolas

@waveform80
Copy link
Owner

What an intriguing bug! Confirmed on 1.12 with the following replication code:

import os
import picamera
import time

nightpath = '.'
camera = picamera.PiCamera(resolution=(1024, 768))
camera.start_preview()

for i, filename in enumerate(
        camera.capture_continuous(
            os.path.join(nightpath, '{timestamp:%H%M%S}.jpg'),
            resize=(640, 480), burst=True, quality=90)):
        sleep = 1
        time.sleep(sleep)

And some captures to demonstrate the duplication (not sure what's going on with 094800.jpg - something weird). I'll try and have a look at this next week.

@waveform80 waveform80 added the bug label Aug 7, 2016
@waveform80 waveform80 self-assigned this Aug 7, 2016
@waveform80 waveform80 added this to the 1.13 milestone Feb 23, 2017
@waveform80
Copy link
Owner

Hmm, that took some work but I've got this fixed up now. Many thanks for mentioning which version worked - that helped a great deal (although unfortunately a huge amount changed under the covers from 1.10 to 1.11 which took some time to dig through - anyway, it was indeed one of those changes that caused the issue).

@alexellis
Copy link

alexellis commented Mar 15, 2019

I feel like I'm seeing the same issue with this code:

  engine = DetectionEngine(args.model)
  labels = ReadLabelFile(args.label) if args.label else None

  with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.framerate = 30
    _, width, height, channels = engine.get_input_tensor_shape()
    camera.start_preview()
    try:
        stream = io.BytesIO()
        for foo in camera.capture_continuous(stream,
                                                format='jpeg',
                                                use_video_port=True,
                                                resize=(width, height)):
            stream.truncate()
            stream.seek(0)
            img = Image.open(stream)

            ans = engine.DetectWithImage(img, threshold=0.1, keep_aspect_ratio=True,
                                            relative_coord=False, top_k=10)
            img=None
            print("ans", ans)     
            if ans:
                for obj in ans:
                    print ('-----------------------------------------')
                    if labels:
                        print(labels[obj.label_id])
                        print ('score = ', obj.score)
    finally:
        camera.stop_preview()
        stream.close()

I can only get different classifications if I close the program and re-open it.

What would you advise? I appear to have "picamera 1.13"

Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants