Skip to content

Commit b954c09

Browse files
author
arch
committed
init commit
1 parent da99ca6 commit b954c09

File tree

170 files changed

+36145
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+36145
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
VERSION.txt
2+
*.egg-info
3+
build
4+
dist

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
help:
3+
@echo "Makefile rules:"
4+
@echo "- all"
5+
@grep ".*:$$" ./Makefile | rev | cut -c 2- | rev | sort | xargs -I{} echo "- {}"
6+
7+
clean:
8+
@rm -rf ./build
9+
@rm -rf *.egg-info
10+
11+
package:
12+
@python3 setup.py bdist_wheel
13+
14+
install:
15+
@find dist -iname "*.whl" | sort | tail -n 1 | xargs -I {} pip3 install --force-reinstall {}
16+
17+
uninstall:
18+
@pip3 uninstall funscript-editor
19+
20+
docs:
21+
@chmod +x docs/code/generate_doc.sh
22+
@docs/code/generate_doc.sh
23+
@bash -c 'cd docs/app && bash build.sh'
24+
25+
all: docs package install clean
26+
27+
.PHONY: docs
28+

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Python Funscript Editor
2+
3+
A Python program to quickly create prototype algorithms to partially automate the generation of funscripts.
4+
5+
**NOTE:** The program is currently not intended for productive use. But you can do whatever you want with this tool.
6+
7+
## Documentation
8+
9+
- The application documentation is located in `./docs/app/site/` (`index.html`).
10+
- The code documentation is located in `./docs/code/_build/html/` (`index.html`).
11+
12+
## Build Pip-Package (Optional)
13+
14+
Generate distribution package of this project. These are archives that can be uploaded to an local Package Index and can be installed by pip.
15+
16+
```bash
17+
make docs package
18+
```
19+
20+
This create the distribution package in `./dist`.

contrib/OpenFunscripter/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Open Funscripter Integration
2+
3+
A hacky lua script to use the python funscript generator scripts in Open Funscripter. Copy the lua script to `data/lua` in your OFS directory. Then adjust the python script path in OFS or direct in the source code. Finally add an shortcut for the script in OFS. The script was only tested on Linux!
4+
5+
**NOTE:** We should use luasockets for the communication but i could not get them to work. I install the lua socket module with `pacman -Sy lua-socket` and compile OFS with dynamic linked library support for lua. But when i load the socket module i got an exception `Symbol not found: some_symbol_name`.
6+
7+
Below the code i used for my first lua socket test:
8+
9+
```lua
10+
package.cpath ="/usr/lib/lua/5.4/?.so;" .. package.cpath
11+
package.path = "/usr/share/lua/5.4/?.lua;" .. package.path
12+
13+
local HOST, PORT = "localhost", 9090
14+
local socket = require('socket')
15+
16+
client, err = socket.connect(HOST, PORT)
17+
client:setoption('keepalive', true)
18+
19+
-- Attempt to ping the server once a second
20+
start = os.time()
21+
while true do
22+
now = os.time()
23+
if os.difftime(now, start) >= 1 then
24+
data = client:send("Hello World")
25+
-- Receive data from the server and print out everything
26+
s, status, partial = client:receive()
27+
print(data, s, status, partial)
28+
start = now
29+
end
30+
end
31+
```
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Settings = {}
2+
Settings.PythonScript = "/home/arch/Repos/private/stroker-robot/Code/Python Funscript Editor/main.py"
3+
Settings.TmpFile = "/tmp/funscript_actions.csv"
4+
SetSettings(Settings)
5+
6+
function GetActions(video)
7+
local at = {}
8+
local pos = {}
9+
local command = 'python3 "'..Settings.PythonScript..'" --generator -s '..tostring(CurrentTimeMs)..' -i "'..video..'" -o "'..Settings.TmpFile..'"'
10+
print(command)
11+
os.execute(command)
12+
local f = io.open(Settings.TmpFile)
13+
if not f then
14+
print('lua: funscript generator output file not found')
15+
return at, pos
16+
end
17+
local k = 1
18+
for line in f:lines() do
19+
-- first line is header
20+
if k > 1 then
21+
for k, v in string.gmatch(line, "(%w+);(%w+)") do
22+
at[#at+1] = k
23+
pos[#pos+1] = v
24+
end
25+
end
26+
k = k + 1
27+
end
28+
f:close()
29+
return at, pos
30+
end
31+
32+
print('start funscript generator')
33+
local video = VideoFilePath -- you have to set the metadata at OFS start
34+
local actions = {GetActions(video)}
35+
for i = 1, #actions[1] do
36+
CurrentScript:AddActionUnordered(tonumber(actions[1][i]), tonumber(actions[2][i]), true, 0)
37+
end
38+
print('done')

docs/app/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# App Documentation
2+
3+
## MkDocs
4+
5+
MkDocs is a fast, simple and downright gorgeous static site generator that's geared towards building project documentation. Documentation source files are written in Markdown, and configured with a single YAML configuration file. There's a single configuration file named `mkdocs.yml` and a folder named `docs` that will contain your documentation source files. ([mkdocs.org](https://www.mkdocs.org/)).
6+
7+
MkDocs comes with a built-in dev-server that lets you preview your documentation as you work on it. Make sure you're in the same directory as the `mkdocs.yml` configuration file, and then start the server by running the `mkdocs serve` command. Open up `http://127.0.0.1:8000/` in your browser, and you'll see the default home. The dev-server also supports auto-reloading, and will rebuild your documentation whenever anything in the configuration file, documentation directory, or theme directory changes.
8+
9+
## Build the Documentation
10+
11+
```bash
12+
mkdocs build
13+
```
14+
15+
This will create a new directory, named `site` with the Documentation.

docs/app/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
mkdocs build
4+
5+
# [ -f ./site/index.html ] && command -v firefox && firefox ./site/index.html & disown

docs/app/docs/index.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Python Funscript Editor
2+
3+
A Python program to quickly create prototype algorithms to partially automate the generation of funscripts.
4+
5+
**NOTE:** The program is currently not intended for productive use. But you can do whatever you want with this tool.
6+
7+
## Algorithms
8+
9+
### Create Funscript Action using OpenCV Tracker
10+
11+
Idea: By using [OpenCV Tracker](https://learnopencv.com/object-tracking-using-opencv-cpp-python/), we can determine the relative movements in a static camera setup and map them into Funscript actions using simple signal processing.
12+
13+
The Algorithm is implemented for 3D Side-By-Side VR Videos. Some parameter are currently hard coded. It should be possible to expand the functionality to 2D Videos by changing the code, with the following limitations.
14+
15+
#### Limitations
16+
17+
- Static camera setup
18+
- Fixed reference point of relative movement in video required
19+
- No video cuts within a tracking sequence allowed
20+
- No change of position of the performers
21+
- Features in the video which are visible in all following frames of the tracking sequence required.
22+
23+
#### Process
24+
25+
1. Selection of the features for the Woman and Men in the video, which should be tracked.
26+
2. Predict the feature positions in the following video frames by OpenCV Tracker.
27+
3. Calculate the difference between the predicted tracking boxes.
28+
4. Map the relative difference to an absolute difference score by user input.
29+
5. Filter all local min and max points to get the final action positions for the Funscript.
30+
31+
### Improvements
32+
33+
- You can change the OpenCV tracker in the source code which predicts the position. OpenCV offers several trackers which differ in prediction accuracy and processing speed. See also [OpenCV Tracker](https://learnopencv.com/object-tracking-using-opencv-cpp-python/).
34+
35+
- You can set the number of frames that are interpolated by the `skip_frames` parameter. 0 means that the OpenCV tracker delivers a prediction for each frame. This is slower but more accurate. Or if greater than zero, the individual frames are skipped and then the tracking boxes are interpolated, which increases the processing speed but decreases the accuracy. I have set the value to 1, i.e. every 2nd frame is skipped and interpolated. Which provides a good mix of accuracy and speed.
36+
37+
- It is recommended to use a low resolution video e.g. 4K for generating the funscript actions, as the processing speed is higher.

docs/app/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
site_name: Funscript Editor

docs/app/site/404.html

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
8+
9+
10+
<link rel="shortcut icon" href="/img/favicon.ico">
11+
<title>Funscript Editor</title>
12+
<link href="/css/bootstrap.min.css" rel="stylesheet">
13+
<link href="/css/font-awesome.min.css" rel="stylesheet">
14+
<link href="/css/base.css" rel="stylesheet">
15+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css">
16+
17+
<script src="/js/jquery-1.10.2.min.js" defer></script>
18+
<script src="/js/bootstrap.min.js" defer></script>
19+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
20+
<script>hljs.initHighlightingOnLoad();</script>
21+
</head>
22+
23+
<body>
24+
<div class="navbar fixed-top navbar-expand-lg navbar-dark bg-primary">
25+
<div class="container">
26+
<a class="navbar-brand" href="/.">Funscript Editor</a>
27+
28+
<!-- Expanded navigation -->
29+
<div id="navbar-collapse" class="navbar-collapse collapse">
30+
31+
<ul class="nav navbar-nav ml-auto">
32+
<li class="nav-item">
33+
<a href="#" class="nav-link" data-toggle="modal" data-target="#mkdocs_search_modal">
34+
<i class="fa fa-search"></i> Search
35+
</a>
36+
</li>
37+
</ul>
38+
</div>
39+
</div>
40+
</div>
41+
42+
<div class="container">
43+
<div class="row">
44+
45+
<div class="row-fluid">
46+
<div id="main-content" class="span12">
47+
<h1 id="404-page-not-found" style="text-align: center">404</h1>
48+
<p style="text-align: center"><strong>Page not found</strong></p>
49+
</div>
50+
</div>
51+
52+
53+
</div>
54+
</div>
55+
56+
<footer class="col-md-12">
57+
<hr>
58+
<p>Documentation built with <a href="https://www.mkdocs.org/">MkDocs</a>.</p>
59+
</footer>
60+
<script>
61+
var base_url = "/",
62+
shortcuts = {"help": 191, "next": 78, "previous": 80, "search": 83};
63+
</script>
64+
<script src="/js/base.js" defer></script>
65+
<script src="/search/main.js" defer></script>
66+
67+
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="searchModalLabel" aria-hidden="true">
68+
<div class="modal-dialog modal-lg">
69+
<div class="modal-content">
70+
<div class="modal-header">
71+
<h4 class="modal-title" id="searchModalLabel">Search</h4>
72+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
73+
</div>
74+
<div class="modal-body">
75+
<p>
76+
From here you can search these documents. Enter
77+
your search terms below.
78+
</p>
79+
<form>
80+
<div class="form-group">
81+
<input type="search" class="form-control" placeholder="Search..." id="mkdocs-search-query" title="Type search term here">
82+
</div>
83+
</form>
84+
<div id="mkdocs-search-results"></div>
85+
</div>
86+
<div class="modal-footer">
87+
</div>
88+
</div>
89+
</div>
90+
</div><div class="modal" id="mkdocs_keyboard_modal" tabindex="-1" role="dialog" aria-labelledby="keyboardModalLabel" aria-hidden="true">
91+
<div class="modal-dialog">
92+
<div class="modal-content">
93+
<div class="modal-header">
94+
<h4 class="modal-title" id="keyboardModalLabel">Keyboard Shortcuts</h4>
95+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
96+
</div>
97+
<div class="modal-body">
98+
<table class="table">
99+
<thead>
100+
<tr>
101+
<th style="width: 20%;">Keys</th>
102+
<th>Action</th>
103+
</tr>
104+
</thead>
105+
<tbody>
106+
<tr>
107+
<td class="help shortcut"><kbd>?</kbd></td>
108+
<td>Open this help</td>
109+
</tr>
110+
<tr>
111+
<td class="next shortcut"><kbd>n</kbd></td>
112+
<td>Next page</td>
113+
</tr>
114+
<tr>
115+
<td class="prev shortcut"><kbd>p</kbd></td>
116+
<td>Previous page</td>
117+
</tr>
118+
<tr>
119+
<td class="search shortcut"><kbd>s</kbd></td>
120+
<td>Search</td>
121+
</tr>
122+
</tbody>
123+
</table>
124+
</div>
125+
<div class="modal-footer">
126+
</div>
127+
</div>
128+
</div>
129+
</div>
130+
131+
</body>
132+
</html>

0 commit comments

Comments
 (0)