rogermiranda1000
Posts: 10
Joined: Sat Mar 31, 2018 8:46 pm

Two applications using the camera

Thu Jun 14, 2018 10:07 am

Is there any way to have two applications use the camera?
Yesterday I installed an application that retransmits the camera on web on-line, and now I can't use mu other python files that make photos.
Here I leave the tutorial and the code of one of my files:
https://elinux.org/RPi-Cam-Web-Interfac ... e_Shooting

Code: Select all

#!/usr/bin/python
import time
import picamera

with picamera.PiCamera() as picx:
    picx.start_preview()
    time.sleep(5)
    picx.capture('mifoto.jpg')
    picx.stop_preview()
    picx.close()

User avatar
DougieLawson
Posts: 32667
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Two applications using the camera

Thu Jun 14, 2018 10:41 am

rogermiranda1000 wrote:
Thu Jun 14, 2018 10:07 am
Is there any way to have two applications use the camera?
Not possible.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 10579
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Two applications using the camera

Thu Jun 14, 2018 11:23 am

No, not at the same time.

But I think that if one application stops using the camera, and relinquishes its use of the camera, that then another application can use the camera afterwards.

Its not as if somehow the camera knows it should only work with the first application that uses it.

I don't know how to relinquish the use of the camera (interface) though, I don't own a raspberry PI cam.

rogermiranda1000
Posts: 10
Joined: Sat Mar 31, 2018 8:46 pm

Re: Two applications using the camera

Thu Jun 14, 2018 11:36 am

Anyone can help me doing this? (Finding the code that makes the website camera works and modify it, so when a photo needs to be made stop using the camera, and then re-activate it)
Or you can recommend me a better option for the website.

User avatar
DougieLawson
Posts: 32667
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Two applications using the camera

Thu Jun 14, 2018 11:46 am

The best way would be to build a "camera server". It grabs the camera and takes a picture when requested.

Your client application would send a request to the server, the server would respond with the filename just captured.

That should be fairly easy to design and build. I'd use MQTT as the command and control process. You could write your own protocol and run a TCP/IP listener of your own.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

rogermiranda1000
Posts: 10
Joined: Sat Mar 31, 2018 8:46 pm

Re: Two applications using the camera

Thu Jun 14, 2018 12:14 pm

OK, I will try it.

rogermiranda1000
Posts: 10
Joined: Sat Mar 31, 2018 8:46 pm

Re: Two applications using the camera

Mon Jun 18, 2018 8:19 pm

I created my own code.
It isn't as good as the other, but it works.
Now I hope I don't have any more problems.
Thanks for your help!

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 14 guests