2017年10月7日土曜日

Acquiring xy and pressure data from a wacom tablet with python

I gave up to acquire xy and pressure data from a wacom tablet with MATLAB, and used python instead.

1) Download python codes.
  I developed codes based on the below URL.
You may find test.py and tablet.py.
 
https://gist.github.com/nitaku/8377916

2) Install Anaconda3


https://www.continuum.io/downloads

Maybe a 32bit version is better for considering the compatibility with the cgkit2 (32bit).

3) Get Python 3.3 
I installed Anaconda3 with Python 3.6 and thus I had to get Python 3.3 in the environment.

   conda create -n py33 python=3.3 anaconda 

4) The way to activate Python 3.3

   activate py33

if you want to go back to the default environment, you can type

   conda deactivate

5) Download and install cgkit 2

  https://sourceforge.net/projects/cgkit/files/cgkit/cgkit-2.0.0/

  cgkit-2.0.0.win32-py3.3.exe (Windows)


* I could not install cgkit 2 because Python 3.3 was not found in Registry, and had to register by myself.

 5-1) Open Registry
     cmd -> regedit

 5-2) Copy the values of Python 3.6 and edit them to go along with Python 3.3.
    "Export -> text edit -> Import" maybe faster than direct editing using GUI.

 5-3) Finally, I installed cgkit 2.

6) Execute "test.py" with WACOM cintiq 13HD

I can acquire the data at 180Hz!

In the test.py,


    p.t, p.x, p.y, p.p

correspond to timestep in the system time(ms), x coodinate, y coordinate, and pressure, respectively.

You can save them like as

   filename = '0001.csv'
   f = open(filename, 'w', newline='')
   csvWriter = csv.writer(f)


   def draw(p):
         :
         :
         csvWriter.writerow([p.t, p.x, p.y, p.p])
         :
   f.close()