Skip to content

This is an unofficial Python library for NIRScanner Nano produced by Texas Instruments.

Notifications You must be signed in to change notification settings

HighTemplar-wjiang/NIRScanner-Python

Repository files navigation

NIRScanner-Python

This is an unofficial Python library for NIRScanner Nano produced by Texas Instruments.

Prerequisite

  • Operating System
    • Only tested on Linux (Ubuntu & Noobs for Pi)
    • Tested with virtual machine (VMWare Workstation Player)
  • Dependencies
    • Python 2.7 or Python 3.5 above
    • Development packages for libudev, libusb. Debian/Ubuntu systems can run:
      sudo apt-get install libudev-dev libusb-1.0-0-dev python-dev python3-dev

Implemented features

  • Perform a scan.
  • Get scanning result.
  • Config the scanning pattern.
  • Set PGA gain.
  • Reset error status.
  • Set hibernation mode.
  • Keep the lamp on / off.

If you need / implemented a new feature, you may send me an email / pull request.

Quick Start

Compile

Already compiled for Debian/Ubuntu systems.

$ cd NIRScanner-Python

For compiling Python 2 library:

NIRScanner-Python$ ./src/scripts/compile_py2.sh

For compiling Python 3 library:

NIRScanner-Python$ ./src/scripts/compile_py3.sh

Deploy

You need _NIRScanner.so and NIRS.py to be in your project path, where _NIRScanner.so is the compiled Python libray, and NIRS.py is the Python Class wrapper.

Python 2

Use _NIRScanner.so.2

NIRScanner-Python$ cp ./lib/_NIRScanner.so.2 <your-project-path>/_NIRScanner.so
NIRScanner-Python$ cp ./lib/NIRS.py <your-project-path>

Python 3

Use _NIRScanner.so.3

NIRScanner-Python$ cp ./lib/_NIRScanner.so.3 <your-project-path>/_NIRScanner.so
NIRScanner-Python$ cp ./lib/NIRS.py <your-project-path>

Raspberry Pi with Python 2

Use _NIRScanner.so.2.pi

NIRScanner-Python$ cp ./lib/_NIRScanner.so.2.pi <your-project-path>/_NIRScanner.so
NIRScanner-Python$ cp ./lib/NIRS.py <your-project-path>

Run

You need root (sudo) permission. Otherwise you may need a workaround such as in [1].

from NIRS import NIRS
nirs = NIRS()
results = nirs.scan()

Note if you are using virtual environment or Anaconda, make sure you are using the absolute python path for sudo.

$ which python
/your/path/to/python
$ sudo /your/path/to/python your_python_code.py

For jupyter

$ which jupyter 
/your/path/to/jupyter
$ sudo /your/path/to/jupyter lab 

That's it.

For more features / examples please refer to test.ipynb (jupyter notebook, also don't forget sudo) and NIRS.py.

[1] https://stackoverflow.com/questions/3738173/why-does-pyusb-libusb-require-root-sudo-permissions-on-linux

FAQ

TBD

License

This repository uses source codes from DLP NIRscan Nano GUI and DLP Spectrum Library, I didn't find any lisence within those repositories, please email me if there is.

About

This is an unofficial Python library for NIRScanner Nano produced by Texas Instruments.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published