Comments (10)
Can you post the code you're using?
from compoundpi.
Sure. This is the code I'm running. Just basic capturing and downloading.
from compoundpi.client import CompoundPiClient
import io
client = CompoundPiClient()
try:
client.servers.network = '192.168.43.1/24'
#client.servers.output = '/home/manan/Desktop/captures'
client.servers.find(10)
client.capture()
for addr, files in client.list().items():
for f in files:
print('Downloading image %d from %s (%d bytes)' % (
f.index,
addr,
f.size,
))
with io.open('%s-%d.jpg' % (addr, f.index)) as f:
client.download(addr, f.index, f)
finally:
client.clear()
client.close()
from compoundpi.
Ah, you're missing the file mode in io.open
. This defaults to 'r'
(read) so you're attempting to open "192.168.43.171-0.jpg" for reading and, naturally, it doesn't exist so you wind up with a no such file or directory error. Just add a 'wb'
parameter to the io.open
call and you should be good to go.
from compoundpi.
Oh this is solved the problem but another I got another one now. It prints the index but shows this error as well.
AttributeError: '_io.BufferedWriter' object has no attribute 'index'
This is while download using client.download(addr, f.index, f)
from compoundpi.
Ah indeed - you've called the open file object f
which overwrites the file metadata object f
. Hence, when it goes to look for f.index
within the with
clause you get an attribute error. I'd suggest calling the open file object something else (have a look at the first example in http://compoundpi.readthedocs.org/en/release-0.4/batch.html#examples which uses "output" as the name instead)
from compoundpi.
Oh yeah. That was the issue. Now it is working fine. But I also need the epoch time in the name of the file. How can I do that?
from compoundpi.
Assuming by "epoch time" you mean "seconds since the UNIX epoch" (i.e. a UNIX timestamp), f.timestamp
will contain the capture timestamp as a datetime
object so you could do something like:
with io.open('%s-%d-%d.jpg' % (addr, f.index, f.timestamp.timestamp())) as output:
client.download(addr, f.index, output)
from compoundpi.
I had tried doing this earlier but what I got was
AttributeError: 'datetime.datetime' object has no attribute 'timestamp'
I googled it but didn't find any conclusive answers.
from compoundpi.
Are you perhaps using Python 2? The timestamp
method for datetime
objects was only added in Python 3. In Python 2 you'd need to do something like:
from time import mktime
...
with io.open('%s-%d-%d.jpg' % (addr, f.index, mktime(f.timestamp.timetuple()))) as output:
client.download(addr, f.index, output)
from compoundpi.
oh yeah !! Thanks for your help!!
from compoundpi.
Related Issues (20)
- Transition to multicast
- Transition to binary protocol
- Recording stop
- Synchronized camera startup
- Run this on Android phones HOT 2
- PiCam v2 support? HOT 2
- RAW Support HOT 3
- Save to Server instead of download to Client? HOT 2
- Server cpid HOT 4
- Error Message when using large number of Pi: CompoundPiTransactionFailed: 1 errors encountered while executing HOT 1
- Sort IP addresses problem
- Stale Sequences on download HOT 3
- PNG and RAW capture HOT 1
- Does this library require internet access?
- Change file names HOT 1
- Errors while capturing and downloading images
- Cant find any servers in GUI mode
- Camera preview? HOT 1
- Pi Camera Module 3 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compoundpi.