diff --git a/cuav/image/scanner.c b/cuav/image/scanner.c index 7edf1ff5..486dffc2 100644 --- a/cuav/image/scanner.c +++ b/cuav/image/scanner.c @@ -1201,9 +1201,13 @@ scanner_thermal_convert(PyObject *self, PyObject *args) for (uint32_t i=0; i>= 2; mask |= value; if (value > maxv) maxv = value; @@ -1214,9 +1218,13 @@ scanner_thermal_convert(PyObject *self, PyObject *args) for (uint32_t i=0; i>= 2; uint8_t map_value(float v, const float threshold) { if (v > threshold) { diff --git a/cuav/uav/uav.py b/cuav/uav/uav.py index 9ff64f52..766dc712 100644 --- a/cuav/uav/uav.py +++ b/cuav/uav/uav.py @@ -1,6 +1,5 @@ from numpy import array, linalg, eye, zeros, dot, transpose from numpy import sin, cos, pi -from matplotlib import pyplot #def rotationMatrix(phi, theta, psi): # out = zeros((3,3)) @@ -91,6 +90,8 @@ def __init__(self, fu=200, fv=200, cu=512, cv=480): if __name__ == '__main__': + from matplotlib import pyplot + xfer = uavxfer() xfer.setCameraParams(200.0, 200.0, 512, 480) xfer.setCameraOrientation(0.0, 0.0, -pi/2) diff --git a/windows/createChangelog.py b/windows/createChangelog.py new file mode 100644 index 00000000..0680c319 --- /dev/null +++ b/windows/createChangelog.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +''' +Create a user readable changelog +Requires the gitpython package via pip install gitpython + +Stephen Dade +November 2016 +''' + +from git import Repo +import os +import time + +#Get the parent (..\) directory. ie the root cuav dir +path = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) +repo = Repo(path) +assert not repo.bare + +#get list of all commits +all_commits = list(repo.iter_commits('master')) + +#open the changelog for writing +f = open("changelog.txt","w") + +#go through all the commits +for comm in all_commits: + #if it's a version raise, add a special message + if "raise version" in comm.message: + commit_date = time.strftime("%d-%m-%Y", time.gmtime(comm.committed_date)) + tree = comm.tree + #get setup.py and grab the version number from the file + blob = tree['setup.py'] + data = blob.data_stream.read() + curversion = "" + for line in data.split('\n'): + if "version = " in line: + curversion = line[11:len(line)-1] + break + + f.write("\n") + f.write("CUAV " + curversion + " (" + commit_date + ")\n") + else: + #just print the summary (1st line) of the commit message + comm.message.split('\n', 1)[0] + f.write("-" + comm.summary + "\n") + +f.close() +print("Done") diff --git a/windows/cuav.spec b/windows/cuav.spec new file mode 100644 index 00000000..f259c81f --- /dev/null +++ b/windows/cuav.spec @@ -0,0 +1,103 @@ +# -*- mode: python -*- +# spec file for pyinstaller to build cuav for windows +geotagAny = Analysis(['.\\cuav\\tools\\geotag.py'], + pathex=[os.path.abspath('.')], + # for some unknown reason these hidden imports don't pull in + # all the needed pieces, so we also import them in mavproxy.py + hiddenimports=['UserList', 'UserString', + 'pymavlink.mavwp', 'pymavlink.mavutil', 'pymavlink.dialects.v20.ardupilotmega', + 'pymavlink.dialects.v10.ardupilotmega', + 'pymavlink.dialects.v20.common', 'pymavlink.dialects.v10.common', + 'pymavlink.dialects.v20.ASLUAV', 'pymavlink.dialects.v10.ASLUAV', + 'pymavlink.dialects.v20.autoquad', 'pymavlink.dialects.v10.autoquad', + 'pymavlink.dialects.v20.matrixpilot', 'pymavlink.dialects.v10.matrixpilot', + 'pymavlink.dialects.v20.minimal', 'pymavlink.dialects.v10.minimal', + 'pymavlink.dialects.v20.paparazzi', 'pymavlink.dialects.v10.paparazzi', + 'pymavlink.dialects.v20.slugs', 'pymavlink.dialects.v10.slugs', + 'pymavlink.dialects.v20.standard', 'pymavlink.dialects.v10.standard', + 'pymavlink.dialects.v20.ualberta', 'pymavlink.dialects.v10.ualberta', + 'pymavlink.dialects.v20.uAvionix', 'pymavlink.dialects.v10.uAvionix'], + excludes=['tcl', 'tk', 'Tkinter', 'tkinter', '_tkinter'], + hookspath=None, + runtime_hooks=None) +pgmconvertAny = Analysis(['.\\cuav\\tools\\pgm_convert.py'], + pathex=[os.path.abspath('.')], + # for some unknown reason these hidden imports don't pull in + # all the needed pieces, so we also import them in mavproxy.py + hiddenimports=['UserList', 'UserString'], + excludes=['tcl', 'tk', 'Tkinter', 'tkinter', '_tkinter'], + hookspath=None, + runtime_hooks=None) +geosearchAny = Analysis(['.\\cuav\\tools\\geosearch.py'], + pathex=[os.path.abspath('.')], + # for some unknown reason these hidden imports don't pull in + # all the needed pieces, so we also import them in mavproxy.py + hiddenimports=['UserList', 'UserString', + 'pymavlink.mavwp', 'pymavlink.mavutil', 'pymavlink.dialects.v20.ardupilotmega', + 'pymavlink.dialects.v10.ardupilotmega', + 'pymavlink.dialects.v20.common', 'pymavlink.dialects.v10.common', + 'pymavlink.dialects.v20.ASLUAV', 'pymavlink.dialects.v10.ASLUAV', + 'pymavlink.dialects.v20.autoquad', 'pymavlink.dialects.v10.autoquad', + 'pymavlink.dialects.v20.matrixpilot', 'pymavlink.dialects.v10.matrixpilot', + 'pymavlink.dialects.v20.minimal', 'pymavlink.dialects.v10.minimal', + 'pymavlink.dialects.v20.paparazzi', 'pymavlink.dialects.v10.paparazzi', + 'pymavlink.dialects.v20.slugs', 'pymavlink.dialects.v10.slugs', + 'pymavlink.dialects.v20.standard', 'pymavlink.dialects.v10.standard', + 'pymavlink.dialects.v20.ualberta', 'pymavlink.dialects.v10.ualberta', + 'pymavlink.dialects.v20.uAvionix', 'pymavlink.dialects.v10.uAvionix'], + excludes=[], + hookspath=None, + runtime_hooks=None) + +MERGE( (geotagAny, 'geotag', 'geotag'), (pgmconvertAny, 'pgmconvert', 'pgmconvert'), (geosearchAny, 'geosearch', 'geosearch') ) + +geotag_pyz = PYZ(geotagAny.pure) +geotag_exe = EXE(geotag_pyz, + geotagAny.scripts, + exclude_binaries=True, + name='geotag.exe', + debug=False, + strip=None, + upx=True, + console=True ) +geotag_coll = COLLECT(geotag_exe, + geotagAny.binaries, + geotagAny.zipfiles, + geotagAny.datas, + strip=None, + upx=True, + name='geotag') + +pgmconvert_pyz = PYZ(pgmconvertAny.pure) +pgmconvert_exe = EXE(pgmconvert_pyz, + pgmconvertAny.scripts, + exclude_binaries=True, + name='pgmconvert.exe', + debug=False, + strip=None, + upx=True, + console=True ) +pgmconvert_coll = COLLECT(pgmconvert_exe, + pgmconvertAny.binaries, + pgmconvertAny.zipfiles, + pgmconvertAny.datas, + strip=None, + upx=True, + name='pgmconvert') + +geosearch_pyz = PYZ(geosearchAny.pure) +geosearch_exe = EXE(geosearch_pyz, + geosearchAny.scripts, + exclude_binaries=True, + name='geosearch.exe', + debug=False, + strip=None, + upx=True, + console=True ) +geosearch_coll = COLLECT(geosearch_exe, + geosearchAny.binaries, + geosearchAny.zipfiles, + geosearchAny.datas, + strip=None, + upx=True, + name='geosearch') \ No newline at end of file diff --git a/windows/cuavWinBuild.bat b/windows/cuavWinBuild.bat new file mode 100644 index 00000000..3f09198e --- /dev/null +++ b/windows/cuavWinBuild.bat @@ -0,0 +1,43 @@ +rem build the standalone Cuav tools for Windows. +rem This assumes Python is installed in C:\Python27 +rem If it is not, change the PYTHON_LOCATION environment variable accordingly +rem This assumes InnoSetup is installed in C:\Program Files (x86)\Inno Setup 5 +rem If it is not, change the INNOSETUP environment variable accordingly +rem This requires the MinGW compiler and libjpeg-turbo development files (libjpeg-turbo-1.5.1-gcc.exe) +rem This requires Pyinstaller==2.1, setuptools==19.2 and packaging==14.2 +rem also requires pyexiv2 - https://launchpad.net/pyexiv2 +SETLOCAL enableextensions + +if "%PYTHON_LOCATION%" == "" (set "PYTHON_LOCATION=C:\Python27") +if "%INNOSETUP%" == "" (set "INNOSETUP=C:\Program Files (x86)\Inno Setup 5") + +rem get the version +for /f "tokens=*" %%a in ( + '"%PYTHON_LOCATION%\python" returnVersion.py' + ) do ( + set VERSION=%%a + ) + +rem -----build the changelog----- +"%PYTHON_LOCATION%\python" createChangelog.py + +rem -----Build CUAV----- +cd ..\ +"%PYTHON_LOCATION%\python" setup.py clean build --compiler=mingw32 install +"%PYTHON_LOCATION%\Scripts\pyinstaller" -y --clean .\windows\cuav.spec + +rem ----Copy the files and scanner.pyd---- +mkdir .\dist\cuav +xcopy .\dist\pgmconvert\* .\dist\cuav /Y /E +xcopy .\dist\geotag\* .\dist\cuav /Y /E +xcopy .\dist\geosearch\* .\dist\cuav /Y /E +xcopy .\build\lib.win32-2.7\cuav\image\scanner.pyd .\dist\cuav\cuav.image.scanner.pyd /Y + +rem -----Create version Info----- +@echo off +@echo %VERSION%> .\windows\version.txt +@echo on + + + +pause diff --git a/windows/returnVersion.py b/windows/returnVersion.py new file mode 100644 index 00000000..0def9f9a --- /dev/null +++ b/windows/returnVersion.py @@ -0,0 +1,12 @@ +# This script reads the setup.py and returns the current version number +# Used as part of building the WIndows setup file (cuavWinBuild.bat) +# It assumes there is a line like this: +# version = "12344" + +# glob supports Unix style pathname extensions +with open("../setup.py") as f: + searchlines = f.readlines() + for i, line in enumerate(searchlines): + if "version = " in line: + print line[11:len(line)-2] + break \ No newline at end of file