Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
update image writing api
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Aug 21, 2018
1 parent de254c9 commit e8697df
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@ python3 -m pip install -e .
```

Running the self-test must be done on a Raspberry Pi with camera module:
```python
```sh
python3 -m pip install -e .[tests]

python3 -m pytest
```

To install advanced (HDF5, NetCDF4) image writing libraries:
```sh
apt install libhdf5-dev

python3 -m pip install -e .[io]
```

### Tips
* Avoid MMAL errors: `raspi-config` → Advanced Options → Memory Split should be 128 MB, not 64 MB.
* Fix error "ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory" by:
Expand Down
2 changes: 1 addition & 1 deletion getrawimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def main():
# NOTE: Didn't use SIGINT to allow camera to cleanup/close--avoid GPU memory leaks!
p = ArgumentParser(description='Raspberry Pi Picamera demo with raw Bayer data')
p.add_argument('exposure', help='exposure time [seconds]', type=float)
p.add_argument('outfn', help='HDF5 or TIFF file to write image stack to', nargs='?')
p.add_argument('outfn', help='HDF5, NetCDF4 or TIFF file to write image stack to', nargs='?')
p.add_argument('-n', '--numimg', help='number of images to write to disk', type=int, default=10)
p.add_argument('-8', '--bit8', help="convert output to 8-bit", action='store_true')
p.add_argument('-p', '--plot', help='show via Matplotlib (slow)s', action='store_true')
Expand Down
6 changes: 3 additions & 3 deletions pibayer/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def writeframes(outfn: Path, img: xarray.DataArray):
import h5py
with h5py.File(outfn, 'w') as f:
f.create_dataset(KEY,
data=img,
data=img.values,
shape=img.shape,
dtype=img.dtype,
compression='gzip',
Expand All @@ -37,6 +37,6 @@ def writeframes(outfn: Path, img: xarray.DataArray):

for k, v in img.attrs.items():
f[k] = v
elif outfn.suffix in ('.tif', '.tiff'): # TIFF
else: # assume stacked image format
import imageio
imageio.imsave(outfn, img)
imageio.mimwrite(outfn, img.values)
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ install_requires =
picamera
numpy
xarray
imageio>=2.3

[options.extras_require]
tests =
Expand Down

0 comments on commit e8697df

Please sign in to comment.