Code Monkey home page Code Monkey logo

pycine's Introduction

pycine

PyPI version GitHub license Code style: black Codacy Badge

Reading Vision Research .cine files with python

Installation

Release Version

With pip

If you have Python 3 installed you can just use pip:

pip3 install -U pycine

Development version

pip install git+https://github.com/ottomatic-io/pycine.git

Example usage

Changing the playback and timecode framerates

pfs_meta set --playback-fps 60/1.001 --timecode_fps 60/1.001 A001C001_190302_16001.cine

You can also set metadata for multiple clips at once:

pfs_meta set --playback-fps 24/1.001 --timecode_fps 24/1.001 *.cine

Help

Every command has its own help output. Just append --help:

$ pfs_meta --help
Usage: pfs_meta [OPTIONS] COMMAND [ARGS]...

  This tool allows .cine file metadata manipulation. Use COMMAND --help for
  more info.

Options:
  --help  Show this message and exit.

Commands:
  copy  Copy metadata from a source clip
  set   Set metadata
  show  Show metadata
$ pfs_meta set --help
Usage: pfs_meta set [OPTIONS] [DESTINATIONS]...

  Set metadata

Options:
  --temp FLOAT          Set color temperature.
  --cc FLOAT            Set color correction.
  --record-fps INTEGER  Set record FPS.
  --playback-fps TEXT   Set playback FPS. Use 60 or 60/1.001 but not 59.94
  --timecode-fps TEXT   Set timecode FPS. Use 60 or 60/1.001 but not 59.94
  --tone TEXT           Set tone curve in the form of "[LABEL] x1 y1 x2 y2".
                        You can set up to 32 xy points.
  --help                Show this message and exit.
$ pfs_raw --help
Usage: pfs_raw [OPTIONS] CINE_FILE [OUT_PATH]

Options:
  --file-format [.png|.jpg|.tif]
  --start-frame INTEGER
  --count INTEGER
  --version                       Show the version and exit.
  --help                          Show this message and exit.

Jupyter notebook

Check out an example on how to use the library from a jupyter notebook: notebooks/Display frames.ipynb

pycine's People

Contributors

cbenhagen avatar codacy-badger avatar dependabot[bot] avatar ehki avatar jsallcock avatar sreich-emi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pycine's Issues

PIMS integration

I am adding .cine capability to pims (Python Image Sequence) by @tcaswell
https://github.com/soft-matter/pims
using python-cine. This will give it more features and a uniform interface to other types of camera files.

However, the GPL3 is inconsistent with the license for PIMS and so the python-cine code and PIMS cannot currently co-exist in a distributable package.

Would it be possible to dual-license the code?

read tagged information blocks: Time only block and Exposure only block

Hi there,
it would be great if also the tagged information blocks would be read out from the cine file, in particular the Time only block, which gives the timestamp of each image and the Exposure only block, which gives the real exposure time of each frame (it may vary for different frames). See page 30 of the cine file format manual (version 2011).
I could not find a way to load that information in the current pycine module.

release a new version for PiPy

Is it possible to release a new version for PiPy with the recent changes, so that all can profit from the improvements?

reading .chd files

.chd header files are created when Phantom software saves the images in a file format other than .cine (.cine docs). It would be good if pycine could read these files too. Apologies if this functionality is already available in the package and i have missed it.

.chd files have exactly the same format as the .cine header, so can be read using a function that is near identical to pycine.file.read_header -- just without the last couple of lines that add the "pImage" key to the header dict.

The proposed function would look something like this:

def read_chd_header(chd_file):
    with open(chd_file, "rb") as f:
        header = {
            "cinefileheader": cine.CINEFILEHEADER(),
            "bitmapinfoheader": cine.BITMAPINFOHEADER(),
            "setup": cine.SETUP(),
        }
        f.readinto(header["cinefileheader"])
        f.readinto(header["bitmapinfoheader"])
        f.readinto(header["setup"])

    return header

What do you think?

interactive cine viewer

I was interested in having a viewer than can go through the cine with some kind slider in a GUI.
I wrote it in my fork using PyQt and pyqtgraph.
adrianroth10/pycine/blob/master/pycine/viewer.py

To make it working I also changed the structure of the frame_reader in raw.py from a yield iterator to a class.

It seems to be working for one of my cine file. What do you think?

different intensity dynamic with import

Dear all,
I use a Phantom highspeed camera which saves the data in cine-files. Therefore I use pycine to open the files and work with them. Overall it works quite nice.
But I found a discepancy between images I export directly from the Phantom software compared to the imported frames via pycine. It is not only a difference in global intensity values as expected for 8, 12 or 16 bit. It is also a different dynamic! Here you see a plot for two different exports from the Software (CV) with different bit depths and from pycine (Python). It is normalized to [0,1] to see the different dynamics.
intensity_Import

I used the following code for saving the frames as tif files:
raw_images, setup, bpp = pycine.raw.read_frames(pin, start_frame=1) for i, raw_image in enumerate(raw_images): imsave(os.path.join(pout, 'frame_py_{}.tif'.format(str(i).zfill(4))), raw_image)

Can someone tell my, why I get different dynamics and how I can solve this issue?

Kind regards
Stefan

Fix bad pixels

The code is already written and being used in production for a long time. It's currently written in cython but could also be ported to plain python if needed.

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.