diff --git a/Examples/.ipynb_checkpoints/BasicExamples_v3-checkpoint.pdf b/Examples/.ipynb_checkpoints/BasicExamples_v3-checkpoint.pdf deleted file mode 100644 index a021fcb..0000000 Binary files a/Examples/.ipynb_checkpoints/BasicExamples_v3-checkpoint.pdf and /dev/null differ diff --git a/Examples/BasicExamples_v3.pdf b/Examples/BasicExamples_v3.pdf deleted file mode 100644 index a021fcb..0000000 Binary files a/Examples/BasicExamples_v3.pdf and /dev/null differ diff --git a/Examples/Instructions_v2.pdf b/Examples/Instructions_v2.pdf deleted file mode 100644 index 9145db3..0000000 Binary files a/Examples/Instructions_v2.pdf and /dev/null differ diff --git a/Examples/SampleMovies/Lab_Original.mp4 b/Examples/SampleMovies/Lab_Original.mp4 deleted file mode 100644 index 20f589a..0000000 Binary files a/Examples/SampleMovies/Lab_Original.mp4 and /dev/null differ diff --git a/Examples/SampleMovies/Synthetic2_DigiPyRo-ed.avi b/Examples/SampleMovies/Synthetic2_DigiPyRo-ed.avi deleted file mode 100644 index a763535..0000000 Binary files a/Examples/SampleMovies/Synthetic2_DigiPyRo-ed.avi and /dev/null differ diff --git a/Examples/SampleMovies/Synthetic2_DigiPyRo-ed_Alt.avi b/Examples/SampleMovies/Synthetic2_DigiPyRo-ed_Alt.avi deleted file mode 100644 index 6c46d11..0000000 Binary files a/Examples/SampleMovies/Synthetic2_DigiPyRo-ed_Alt.avi and /dev/null differ diff --git a/Examples/SampleMovies/Synthetic2_DigiPyRo-ed_Alt2.avi b/Examples/SampleMovies/Synthetic2_DigiPyRo-ed_Alt2.avi deleted file mode 100644 index 35cacfb..0000000 Binary files a/Examples/SampleMovies/Synthetic2_DigiPyRo-ed_Alt2.avi and /dev/null differ diff --git a/Examples/SampleMovies/Synthetic2_Original.avi b/Examples/SampleMovies/Synthetic2_Original.avi deleted file mode 100644 index de9306f..0000000 Binary files a/Examples/SampleMovies/Synthetic2_Original.avi and /dev/null differ diff --git a/Examples/SampleMovies/Synthetic2_Original_Alt.avi b/Examples/SampleMovies/Synthetic2_Original_Alt.avi deleted file mode 100644 index 354be0c..0000000 Binary files a/Examples/SampleMovies/Synthetic2_Original_Alt.avi and /dev/null differ diff --git a/Examples/SampleMovies/Synthetic2_Original_Rot.avi b/Examples/SampleMovies/Synthetic2_Original_Rot.avi deleted file mode 100644 index 1bb55a7..0000000 Binary files a/Examples/SampleMovies/Synthetic2_Original_Rot.avi and /dev/null differ diff --git a/Examples/SampleMovies/Synthetic_DigiPyRo-ed_Alt.avi b/Examples/SampleMovies/Synthetic_DigiPyRo-ed_Alt.avi deleted file mode 100644 index c362f61..0000000 Binary files a/Examples/SampleMovies/Synthetic_DigiPyRo-ed_Alt.avi and /dev/null differ diff --git a/Examples/SampleMovies/Synthetic_Original_Alt.avi b/Examples/SampleMovies/Synthetic_Original_Alt.avi deleted file mode 100644 index c7d08a6..0000000 Binary files a/Examples/SampleMovies/Synthetic_Original_Alt.avi and /dev/null differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..37ec93a --- /dev/null +++ b/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fb4b8d1 --- /dev/null +++ b/README.md @@ -0,0 +1,196 @@ +![](https://github.com/DJ-2805/DigiPyRo/blob/master/util/SpinLabUCLA_BW_strokes.png) + +DigiPyRo is a program designed to digitally rotate a movie and allows +for single-particle tracking. This was originally designed to +intuitively show Coriolis force effects through the appearance of +inertial circles when digitally rotating film of a ball oscillating on a +parabolic surface. + +The Python 2.7 version of the code was created by [Sam +May](https://github.com/sam-may/DigiPyRo) and the current version is +maintained by [David James](https://github.com/DJ-2805) in conjunction +with the [SPIN Lab](https://spinlab.epss.ucla.edu/) at UCLA. + +Setup +===== + +You'll first need to get the files needed to install and run DigiPyRo. + +1. First download the files needed. You can either follow + [this](https://github.com/DJ-2805/DigiPyRo) and download the files + or if you have `git` on your terminal you can download through + terminal. + + ``` {.bash} + git clone https://github.com/dj-2805/digipyro + ``` + + - If you instead followed the link, then click on the green + `Clone or download` button, and download the repository into + your machine + +Installation +============ + +This SOP assumes that you have python already installed. Before you get +to run DigiPyRo you'll need to install the dependencies so the program +can run. Because of how most of this program is setup, you will do most +of the interaction with code through the terminal. + +1. If you are on Windows, open the `Powershell`. If you are on Mac, + open the `Terminal`. +2. To verify that you do have Python, run the following command + + ``` {.bash} + # windows machine + python --version + + # MAC machine + python3 --version + ``` + + - you should see an output of Python 3.x.x version number. If you + see Python 2.x.x, you will need to reinstall your Python. + + - NOTE :: Some machines need `python3` being called explicitly + rather than `python` in terminal calls. If this produces the + correct version, then any future commands you see in the rest of + the instructions will require `python3` being typed rather than + `python` + +3. First make sure your package manager is up-to-date. + + ``` {.bash} + # if you are on a Windows machine, run this command + python -m pip install --upgrade pip + + # if you are on a Mac, run this command + pip install --upgrade pip + ``` + +4. Next you will need to move over to the the directory that contains + the files that you unzipped. +5. Now you'll be installing the dependencies. + + ``` {.bash} + pip install -r requirements.txt + ``` + +Synthetic Movie Program +======================= + +At this point, you should have Python and all the dependencies to run +the programs. This first program creates a synthetic .avi movie for use +with DigiPyRo. If you already have a film from experimentation, then you +can skip this program, and move to the DigiPyRo program below. + +The video shows a ball rolling on a parabolic surface, where the user +may change the video length of the movie, frame rate, resolution, +frequency of oscillations, rotation rate of the reference frame, and +control the inital conditions of the ball. + +1. You will still need the terminal at this point, so open it up if you + have closed it. +2. To see the `help` message for the the movie program type + + ``` {.bash} + python synth.py -h + # or + python synth.py --help + ``` + +3. You should see the following messaged + + ``` {.org} + usage: synth.py [-h] [-t TIME] [-f FPS] [-w WIDTH] [-l LENGTH] [-r EQPOT_RPM] [-R CAM_RPM] [--r0 R0] [--vr0 VR0] [--phi0 PHI0] [--vphi0 VPHI0] + + This program creates a synthetic .avi movie for use with DigiPyRo. The video shows a ball rolling on a parabolic surface. The user may change the length of the movie, + the frame rate, the resolution of the movie, the frequency of oscillations, the rotation rate of the reference frame, and control the initial conditions of the ball. + + optional arguments: + -h, --help show this help message and exit + -t TIME, --time TIME The desired length of the movie in seconds. (default: 5) + -f FPS, --fps FPS The frame rate of the video (frames per second). Set this to a low value (10-15) for increased speed or a higher value (30-60) for better + results. (default: 30.0) + -w WIDTH, --width WIDTH + The width in pixels of the video. (default: 1260) + -l LENGTH, --length LENGTH + The height in pixels of the video. (default: 720) + -r EQPOT_RPM, --eqpot_rpm EQPOT_RPM + The deflection of a stationary paraboloid surface as if it were an equipotentional in a system rotating at the specified rate. A good value + would be between 5 and 15. (default: 10.0) + -R CAM_RPM, --cam_rpm CAM_RPM + The rotation rate of the camera. The two natural frames of reference are with rotRate = 0 and rotRate = rpm. (default: 0.0) + --r0 R0 The initial radial position of the ball. Choose a value betweeon 0 and 1. (default: 1.0) + --vr0 VR0 The initial radial velocity of the ball. A good value would be between 0 and 1. (default: 0.0) + --phi0 PHI0 The initial azimuthal position of the ball. Choose a value between 0 and 2*pi. (default: 0.7853981633974483) + --vphi0 VPHI0 The initial azimuthal velocity of the ball. A good value would be between 0 and 1. (default: 0) + ``` + +4. The program has several flags, and all of them have default values + described in the help message. The program can be run in several + different ways, where you run it with it's defualt values or you + change the flags desired to have a video produced. Note, when you do + run it, you'll be prompted for a movie name. The produced movie will + be in `.avi` format, so only a movie name will be needed. Examples + are shown below: + + ``` {.bash} + # running the program with just its default values + python synth.py + + # running the program with changing one value + python synth.py -t 10 + + # the same but using the full flag name + python synth.py --time 10 + + # running the program with multiple flags + python synth.py -t 7 -r 15 --vr0 3 + ``` + + NOTE + : Depending on the parameters given and how powerful your machine + is, this could take a couple minutes for it to create your film. + +5. After the program completes, you should see your movie file created + in the same directory. + +DigiPyRo Program +================ + +Now to run the DigiPyRo program you'll need a video and to set some +parameters. The DigiPyRo program runs through a GUI, but will still need +a terminal command to get the program started. + +1. Run the following command to get DigiPyRo started. + + ``` {.bash} + python DigiPyRo.py + ``` + +2. You will see a GUI window appear, where you can input values for + each area. +3. The values are based on either the video you created from synth.py + or a lab experiment you ran beforehand. +4. For the `full filepath to movie` parameter, unless the video is in + the same directory as `DigiPyRo.py`, you must specify the entire + path. Furthermore, you must specify the extension of the movie (i.e. + .avi, .mp4, etc.). +5. For the `Save output video as` parameter, only the file name needs + to be given. The extension will be added after the program executes. +6. For the `Start and end times` parameter, the end time should be a + bit shorter of the true end of the film (i.e. if the film is 5 secs + long then this `end time` should go to 4.8). This is a current bug + that I came across; sometimes the program goes out of index if the + full length of the film is given. +7. For more description and instructions on the programs refer to + [Sam's Instruction + PDF](https://github.com/DJ-2805/DigiPyRo/blob/master/Examples/BasicExamples_v3.pdf). + + NOTE + : Sam's PDF is out-of-date for some instructions, because the + program has been changed, but still gives description and images + on some of the steps. + + diff --git a/README.org b/README.org deleted file mode 100644 index 89d3434..0000000 --- a/README.org +++ /dev/null @@ -1,124 +0,0 @@ -#+TITLE: Standard Operating Procedure -#+AUTHOR: David James, davidabraham@ucla.edu -#+DATE: 2020 April 04 - -[[https://github.com/DJ-2805/DigiPyRo/blob/master/util/SpinLabUCLA_BW_strokes.png]] - -DigiPyRo is a program designed to digitally rotate a movie and allows for -single-particle tracking. This was originally designed to intuitively show -Coriolis force effects through the appearance of inertial circles when digitally -rotating film of a ball oscillating on a parabolic surface. - -The Python 2.7 version of the code was created by [[https://github.com/sam-may/DigiPyRo][Sam May]] and the current -version is maintained by [[https://github.com/DJ-2805][David James]] in conjunction with the [[https://spinlab.epss.ucla.edu/][SPIN Lab]] at UCLA. - -* Setup - You'll first need to get the files needed to install and run DigiPyRo. - 1. First download the files needed. You can either follow [[https://github.com/DJ-2805/DigiPyRo][this]] and download the files or if you have ~git~ on your terminal you can download through terminal. - #+BEGIN_SRC bash - git clone https://github.com/dj-2805/digipyro - #+END_SRC - - If you instead followed the link, then click on the green ~Clone or download~ button, and download the repository into your machine - -* Installation - This SOP assumes that you have python already installed. Before you get to run - DigiPyRo you'll need to install the dependencies so the program can run. - Because of how most of this program is setup, you will do most of the - interaction with code through the terminal. - 1. If you are on Windows, open the ~Powershell~. If you are on Mac, open the ~Terminal~. - 2. To verify that you do have Python, run the following command - #+BEGIN_SRC bash - # windows machine - python --version - - # MAC machine - python3 --version - #+END_SRC - - you should see an output of Python 3.x.x version number. If you see Python 2.x.x, you will need to reinstall your Python. - - - NOTE :: Some machines need =python3= being called explicitly rather than =python= in terminal calls. If this produces the correct version, then any future commands you see in the rest of the instructions will require =python3= being typed rather than =python= - 3. First make sure your package manager is up-to-date. - #+BEGIN_SRC bash - # if you are on a Windows machine, run this command - python -m pip install --upgrade pip - - # if you are on a Mac, run this command - pip install --upgrade pip - #+END_SRC - 4. Next you will need to move over to the the directory that contains the files that you unzipped. - 5. Now you'll be installing the dependencies. - #+BEGIN_SRC bash - pip install -r requirements.txt - #+END_SRC -* Synthetic Movie Program - At this point, you should have Python and all the dependencies to run the - programs. This first program creates a synthetic .avi movie for use with - DigiPyRo. If you already have a film from experimentation, then you can skip - this program, and move to the DigiPyRo program below. - - The video shows a ball rolling on a parabolic surface, where the user may - change the video length of the movie, frame rate, resolution, frequency of - oscillations, rotation rate of the reference frame, and control the inital - conditions of the ball. - 1. You will still need the terminal at this point, so open it up if you have closed it. - 2. To see the ~help~ message for the the movie program type - #+BEGIN_SRC bash - python synth.py -h - # or - python synth.py --help - #+END_SRC - 3. You should see the following messaged - #+BEGIN_SRC org - usage: synth.py [-h] [-t TIME] [-f FPS] [-w WIDTH] [-l LENGTH] [-r EQPOT_RPM] [-R CAM_RPM] [--r0 R0] [--vr0 VR0] [--phi0 PHI0] [--vphi0 VPHI0] - - This program creates a synthetic .avi movie for use with DigiPyRo. The video shows a ball rolling on a parabolic surface. The user may change the length of the movie, - the frame rate, the resolution of the movie, the frequency of oscillations, the rotation rate of the reference frame, and control the initial conditions of the ball. - - optional arguments: - -h, --help show this help message and exit - -t TIME, --time TIME The desired length of the movie in seconds. (default: 5) - -f FPS, --fps FPS The frame rate of the video (frames per second). Set this to a low value (10-15) for increased speed or a higher value (30-60) for better - results. (default: 30.0) - -w WIDTH, --width WIDTH - The width in pixels of the video. (default: 1260) - -l LENGTH, --length LENGTH - The height in pixels of the video. (default: 720) - -r EQPOT_RPM, --eqpot_rpm EQPOT_RPM - The deflection of a stationary paraboloid surface as if it were an equipotentional in a system rotating at the specified rate. A good value - would be between 5 and 15. (default: 10.0) - -R CAM_RPM, --cam_rpm CAM_RPM - The rotation rate of the camera. The two natural frames of reference are with rotRate = 0 and rotRate = rpm. (default: 0.0) - --r0 R0 The initial radial position of the ball. Choose a value betweeon 0 and 1. (default: 1.0) - --vr0 VR0 The initial radial velocity of the ball. A good value would be between 0 and 1. (default: 0.0) - --phi0 PHI0 The initial azimuthal position of the ball. Choose a value between 0 and 2*pi. (default: 0.7853981633974483) - --vphi0 VPHI0 The initial azimuthal velocity of the ball. A good value would be between 0 and 1. (default: 0) - #+END_SRC - 4. The program has several flags, and all of them have default values described in the help message. The program can be run in several different ways, where you run it with it's defualt values or you change the flags desired to have a video produced. Note, when you do run it, you'll be prompted for a movie name. The produced movie will be in ~.avi~ format, so only a movie name will be needed. Examples are shown below: - #+BEGIN_SRC bash - # running the program with just its default values - python synth.py - - # running the program with changing one value - python synth.py -t 10 - - # the same but using the full flag name - python synth.py --time 10 - - # running the program with multiple flags - python synth.py -t 7 -r 15 --vr0 3 - #+END_SRC - - NOTE :: Depending on the parameters given and how powerful your machine is, this could take a couple minutes for it to create your film. - 5. After the program completes, you should see your movie file created in the same directory. -* DigiPyRo Program - Now to run the DigiPyRo program you'll need a video and to set some parameters. The DigiPyRo program runs through a GUI, but will still need a terminal command to get the program started. - 1. Run the following command to get DigiPyRo started. - #+BEGIN_SRC bash - python DigiPyRo.py - #+END_SRC - 2. You will see a GUI window appear, where you can input values for each area. - 3. The values are based on either the video you created from synth.py or a lab experiment you ran beforehand. - 4. For the ~full filepath to movie~ parameter, unless the video is in the same directory as ~DigiPyRo.py~, you must specify the entire path. Furthermore, you must specify the extension of the movie (i.e. .avi, .mp4, etc.). - 5. For the ~Save output video as~ parameter, only the file name needs to be given. The extension will be added after the program executes. - 6. For the ~Start and end times~ parameter, the end time should be a bit shorter of the true end of the film (i.e. if the film is 5 secs long then this ~end time~ should go to 4.8). This is a current bug that I came across; sometimes the program goes out of index if the full length of the film is given. - 7. For more description and instructions on the programs refer to [[https://github.com/DJ-2805/DigiPyRo/blob/master/Examples/BasicExamples_v3.pdf][Sam's Instruction PDF]]. - - NOTE :: Sam's PDF is out-of-date for some instructions, because the program has been changed, but still gives description and images on some of the steps. diff --git a/DigiPyRo.py b/digipyro/scripts/digipyro.py similarity index 99% rename from DigiPyRo.py rename to digipyro/scripts/digipyro.py index fc79521..31aec2a 100644 --- a/DigiPyRo.py +++ b/digipyro/scripts/digipyro.py @@ -354,7 +354,7 @@ def start(): global width, height, numFrames, fps, fourcc, video_writer, spinlab, npts # declare these variables as global so they can be used by helper functions without being explicitly passed as arguments npts = 0 # number of user-clicked points along circumference of circle/polygon - spinlab = cv2.imread('util/SpinLabUCLA_BW_strokes.png') # spinlab logo to display in upper right corner of output video + spinlab = cv2.imread('../../doc/SpinLabUCLA_BW_strokes.png') # spinlab logo to display in upper right corner of output video width = int(vid.get(cv2.CAP_PROP_FRAME_WIDTH)) height = int(vid.get(cv2.CAP_PROP_FRAME_HEIGHT)) # read the width and height of input video. output video will have matching dimensions fps = fpsVar.get() diff --git a/synth.py b/digipyro/scripts/synth.py similarity index 98% rename from synth.py rename to digipyro/scripts/synth.py index 4055fbe..87dda3e 100644 --- a/synth.py +++ b/digipyro/scripts/synth.py @@ -54,16 +54,15 @@ # collecting user input into list args = parser.parse_args() - -spinlab = cv2.imread('util/SpinLabUCLA_BW_strokes.png') # spinlab logo to display in upper right corner of output video - + # spinlab logo to display in upper right corner of output video +# spinlab = cv2.imread('../../doc/SpinLabUCLA_BW_strokes.png') # Define movie details movLength = args.time # [1] define the desired length of the movie in seconds fps = args.fps # [2] Set this to a low value (10-15) for increased speed or a higher value (30-60) for better results with DigiPyRo width = args.width # [3] Width and height in pixels height = args.length # [3] Decrease the width and height for increased speed, increase for improved resolution -spinlab = cv2.resize(spinlab,(int(0.2*width),int((0.2*height)/3)), interpolation = cv2.INTER_CUBIC) +# spinlab = cv2.resize(spinlab,(int(0.2*width),int((0.2*height)/3)), interpolation = cv2.INTER_CUBIC) # Define table values @@ -157,7 +156,7 @@ def annotate(img, i, rotatingView): # puts diagnostic text info on each frame rotViewLoc = (25, 130) cv2.putText(img, rotView, rotViewLoc, font, 1, (255, 105, 180), 1) - img[25:25+spinlab.shape[0], (width-25)-spinlab.shape[1]:width-25] = spinlab + # img[25:25+spinlab.shape[0], (width-25)-spinlab.shape[1]:width-25] = spinlab timestamp = 'Time: ' + str(round((i/fps),1)) + ' s' tLoc = (width - 225, height-25) diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/doc/conf.py b/doc/conf.py new file mode 100644 index 0000000..666a064 --- /dev/null +++ b/doc/conf.py @@ -0,0 +1,52 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'digipyro' +copyright = '2020, The DIYnamics Team' +author = 'The DIYnamics Team' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] \ No newline at end of file diff --git a/doc/index.rst b/doc/index.rst new file mode 100644 index 0000000..b774b1f --- /dev/null +++ b/doc/index.rst @@ -0,0 +1,20 @@ +.. digipyro documentation master file, created by + sphinx-quickstart on Mon May 11 20:22:06 2020. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to digipyro's documentation! +==================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 0000000..2119f51 --- /dev/null +++ b/doc/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/Examples/SampleMovies/Lab_DigiPyRo-ed.avi b/sample_movies/Lab_DigiPyRo-ed.avi similarity index 100% rename from Examples/SampleMovies/Lab_DigiPyRo-ed.avi rename to sample_movies/Lab_DigiPyRo-ed.avi diff --git a/Examples/SampleMovies/Lab_Masked.avi b/sample_movies/Lab_Masked.avi similarity index 100% rename from Examples/SampleMovies/Lab_Masked.avi rename to sample_movies/Lab_Masked.avi diff --git a/Examples/SampleMovies/Synthetic_DigiPyRo-ed.avi b/sample_movies/Synthetic_DigiPyRo-ed.avi similarity index 100% rename from Examples/SampleMovies/Synthetic_DigiPyRo-ed.avi rename to sample_movies/Synthetic_DigiPyRo-ed.avi diff --git a/Examples/SampleMovies/Synthetic_Original.avi b/sample_movies/Synthetic_Original.avi similarity index 100% rename from Examples/SampleMovies/Synthetic_Original.avi rename to sample_movies/Synthetic_Original.avi diff --git a/Examples/SampleMovies/Synthetic_Original_Rot.avi b/sample_movies/Synthetic_Original_Rot.avi similarity index 100% rename from Examples/SampleMovies/Synthetic_Original_Rot.avi rename to sample_movies/Synthetic_Original_Rot.avi diff --git a/sample_movies/test_digipyro.avi b/sample_movies/test_digipyro.avi new file mode 100644 index 0000000..d88fdfd Binary files /dev/null and b/sample_movies/test_digipyro.avi differ diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..19c797c --- /dev/null +++ b/setup.py @@ -0,0 +1,32 @@ +import setuptools + +setuptools.setup( + name="digipyro", + version="0.0", + packages=setuptools.find_packages(), + author="The DIYnamics Team", + author_email="DIYnamicsTeam@gmail.com", + description="Digitally Rotate a movie in Python", + install_requires=[ + "numpy", + "scipy", + "matplotlib", + "opencv-python", + "tk", + ], + scripts=[ + "digipyro/scripts/digipyro.py", + "digipyro/scripts/synth.py"] + , + license="Apache", + keywords="education", + url="https://github.com/DIYnamics/digipyro", + classifiers=[ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Topic :: Scientific/Engineering :: Atmospheric Science" + ] +) diff --git a/util/InertialCircleAnimations.nb b/util/InertialCircleAnimations.nb deleted file mode 100644 index 108a268..0000000 --- a/util/InertialCircleAnimations.nb +++ /dev/null @@ -1,95 +0,0 @@ -(* The following code can be copy-pasted into a Mathematica notebook, \ -allowing the user to create inertial circle videos AND to \ -interactively manipulate initial conditions and time. \ - -NOTE: This notebook was written in Mathematica 9 - -To get a feel for the capabilities of the notebook, I recommend first \ -playing around a little. \ -(1) Execute the notebook by pressing SHIFT+ENTER. -(2) Watch the particle's motion evolve in time by using the \ -slider labeled "time". -(3) Watch the particle's motion change as a function of initial \ -azimuthal velocity by using the slider labeled "v\[Phi]0]". - -Now, what is shown in the "inertial frame" and "rotating frame" paths? \ -Consider a paraboloid formed by a 2d surface that rotates while under \ -the influence of gravity (gravity acts in the same direction as the \ -axis of rotation). The "inertial frame" shows the motion of a free \ -particle on this parabolic surface. The "rotating frame" shows the \ -motion of a free particle as viewed from a frame co-rotating with the \ -2d surface. That is, the rotating frame has the same angular \ -frequency as the angular frequency which formed the paraboloid. *) \ - - -Remove["Global`*"] -\[CapitalOmega] = 1; (* angular velocity of paraboloid *) -vr0 = 0; (* initial radial velocity *) -r0 = 1; (* initial radial position *) -v\[Phi]0 = -1.3; (* initial azimuthal velocity *) -\[Phi]0 = Pi/4; (* initial azimuthal position *) - - -(* Equations of motion of a particle moving on a parabolic surface \ -(making the approximation that gravity is much greater than the rotation rate -- \ -that is, g >> \[CapitalOmega]^2 *) -r[t_, v\[Phi]0_] := ((((vr0^2 + - r0^2 v\[Phi]0^2) (Sin[\[CapitalOmega] \ -t])^2)/\[CapitalOmega]^2) + ((r0 vr0 Sin[ - 2 \[CapitalOmega] t])/\[CapitalOmega]) + (r0^2 (Cos[\ -\[CapitalOmega] t])^2))^(1/2); -\[Theta][t_, v\[Phi]0_] := - ArcTan[(((Sin[\[CapitalOmega] t]) (vr0 Cos[\[Phi]0] - - r0 v\[Phi]0 Sin[\[Phi]0]))/\[CapitalOmega]) + - r0 Cos[\[Phi]0] Cos[\[CapitalOmega] t], (((Sin[\[CapitalOmega] \ -t]) (vr0 Sin[\[Phi]0] + r0 v\[Phi]0 Cos[\[Phi]0]))/\[CapitalOmega]) + - r0 Sin[\[Phi]0] Cos[\[CapitalOmega] t]]; - -(* Azimuthal coordinate when transformed to a rotating frame *) -\[Theta]r[t_, - v\[Phi]0_] := \[Theta][t, v\[Phi]0] + \[CapitalOmega] t; - -(* Convert equations of motion from polar coordinates to cartesian coordinates *) -xi[t_, v\[Phi]0_] := r[t, v\[Phi]0] Cos[\[Theta][t, v\[Phi]0]]; -yi[t_, v\[Phi]0_] := r[t, v\[Phi]0] Sin[\[Theta][t, v\[Phi]0]]; -xr[t_, v\[Phi]0_] := r[t, v\[Phi]0] Cos[\[Theta]r[t, v\[Phi]0]]; -yr[t_, v\[Phi]0_] := r[t, v\[Phi]0] Sin[\[Theta]r[t, v\[Phi]0]]; - -circleList = {Circle[{0, 0}, 0.5], Circle[{0, 0}, 1], - Circle[{0, 0}, 1.5], Circle[{0, 0}, 2.0]}; - -(* Remove the semicolon from the following line to create a movie \ -which shows one period of oscillation in the inertial frame (in blue) \ -and in the rotating frame (in red) *) -timeMov = - Animate[ParametricPlot[{{xi[t, v\[Phi]0], - yi[t, v\[Phi]0]}, {xr[t, v\[Phi]0], yr[t, v\[Phi]0]}}, {t, 0, - tf}, PlotRange -> {{-2, 2}, {-2, 2}}, - PlotStyle -> {{Blue, Thickness[0.01]}, {Red, Thickness[0.01]}}, - PlotLabel -> {Style[Framed["Inertial Frame"], 16, Blue], - Style[Framed["Rotating Frame"], 16, Red]}, - Epilog -> {Dashed, Thickness[0.001], circleList}], {tf, -0.1, -2* - Pi}]; - -(* Remove the semicolon from the following line to create a movie \ -which varies the initial azimuthal velocity *) -phiMov = Animate[ - ParametricPlot[{{xi[t, v\[Phi]0], - yi[t, v\[Phi]0]}, {xr[t, v\[Phi]0], yr[t, v\[Phi]0]}}, {t, - 0, -2*Pi}, PlotRange -> {{-2, 2}, {-2, 2}}, - PlotStyle -> {{Blue, Thickness[0.01]}, {Red, Thickness[0.01]}}, - PlotLabel -> {Style[Framed["Inertial Frame"], 16, Blue], - Style[Framed["Rotating Frame"], 16, Red]}, - Epilog -> {Dashed, Thickness[0.001], circleList}], {v\[Phi]0, - 0, -2}]; - -(* Remove the semicolon from the following line to simultaneously \ -manipulate the initial azimuthal velocity AND the time *) -Manipulate[ - ParametricPlot[{{xi[t, v\[Phi]0], yi[t, v\[Phi]0]}, {xr[t, v\[Phi]0], - yr[t, v\[Phi]0]}}, {t, 0, time}, PlotRange -> {{-2, 2}, {-2, 2}}, - PlotStyle -> {{Blue, Thickness[0.01]}, {Red, Thickness[0.01]}}, - PlotLabel -> {Style[Framed["Inertial Frame"], 16, Blue], - Style[Framed["Rotating Frame"], 16, Red]}, - Epilog -> {Dashed, Thickness[0.001], circleList}], {v\[Phi]0, -2, - 2}, {time, -0.01, -2*Pi}] diff --git a/util/SpinLabUCLA_BW_strokes.png b/util/SpinLabUCLA_BW_strokes.png deleted file mode 100644 index 9c38556..0000000 Binary files a/util/SpinLabUCLA_BW_strokes.png and /dev/null differ diff --git a/util/install.sh b/util/install.sh deleted file mode 100644 index 63488e5..0000000 --- a/util/install.sh +++ /dev/null @@ -1,81 +0,0 @@ -# Need to have Xcode and command line tools installed! -xcode-select --install - -# Install homebrew -pushd ~ -which -s brew -if [[ $? != 0 ]] ; then - # Install Homebrew - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -else - brew update -fi - -# Install python -which -s python -if [[ $? != 0 ]] ; then - # Install python - brew install python -fi - -# Upgrade python packages -# FIXME: Do I need to check if user has pip installed? Is pip installed by default with any version of python? -pip install numpy --upgrade -pip install scipy --upgrade -pip install matplotlib --upgrade - -# Make sure that the user's python is /usr/local/bin/python -pythonLocation=$(which python) -pythonDesiredLocation="/usr/local/bin/python" -if [ "$pythonLocation" != "$pythonDesiredLocation" ] ; then - echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile - #echo "OpenCV needs your default Python to be located in /usr/local/bin/python" - #echo "In other words, the command `which python` needs to output /usr/local/bin/python" - #exit 1 -fi - -# Get openCV -brew tap homebrew/science -brew install opencv@2 -brew install pkg-config - - -# Check if sysctl is in path -if ! [ -x "$(command -v sysctl)" ]; then - echo "Sysctl not found in path, trying to fix" - if [ -d "/sbin" ]; then - echo 'export PATH="/sbin:$PATH" '>> ~/.bash_profile - fi - if [ -d "/usr/sbin" ]; then - echo 'export PATH="/usr/sbin:$PATH" '>> ~/.bash_profile - fi -fi - -# Next two are bc opencv@2 is a "keg-only" package (i.e. not the most recent version) -echo 'export PATH="/sbin:$PATH" '>> ~/.bash_profile -echo 'export PATH="/usr/local/opt/opencv@2/bin:$PATH"' >> ~/.bash_profile -export PKG_CONFIG_PATH="/usr/local/opt/opencv@2/lib/pkgconfig:$PKG_CONFIG_PATH" - -# Grab openCV version -opencvVersion=$(pkg-config --modversion opencv) - -cat ~/.bash_profile | grep PYTHONPATH - -# Symlinks for opencv to find python -ln -sf /usr/local/Cellar/opencv\@2/$opencvVersion/lib/python2.7/site-packages/cv.py cv.py -ln -sf /usr/local/Cellar/opencv\@2/$opencvVersion/lib/python2.7/site-packages/cv2.so cv2.so - -source ~/.bash_profile - -if ! [ -x "$(command -v sysctl)" ]; then - echo "Still unable to find systcl :(" -else - echo "Successfully found sysctl! :)" -fi - -# Download DigiPyRo -popd -if [ ! -d "DigiPyRo" ] ; then - git clone https://github.com/sam-may/DigiPyRo - git checkout master -fi