Skip to content

Commit

Permalink
migrated to vite
Browse files Browse the repository at this point in the history
  • Loading branch information
jyjblrd committed Jul 27, 2023
1 parent 588fba7 commit 9d8bea1
Show file tree
Hide file tree
Showing 26 changed files with 5,592 additions and 189 deletions.
Binary file modified .DS_Store
Binary file not shown.
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
__pycache__
186 changes: 0 additions & 186 deletions app/nextjs-flask/api/index.py

This file was deleted.

Binary file added ball.stl
Binary file not shown.
4 changes: 2 additions & 2 deletions mocap/capture_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import cv2 as cv

c = Camera(fps=150, resolution=Camera.RES_SMALL, gain=0, exposure=100)
c = Camera(fps=150, resolution=Camera.RES_SMALL, gain=15, exposure=100)

camera_params = [
{
Expand Down Expand Up @@ -39,7 +39,7 @@ def init_frame(img, camera_num):
def find_dot(img):
img = cv.GaussianBlur(img,(5,5),0)
grey = cv.cvtColor(img, cv.COLOR_RGB2GRAY)
grey = cv.threshold(grey, 255*0.4, 255, cv.THRESH_BINARY)[1]
grey = cv.threshold(grey, 255*0.2, 255, cv.THRESH_BINARY)[1]
contours,_ = cv.findContours(grey, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
img = cv.drawContours(img, contours, -1, (0,255,0), 1)

Expand Down
16 changes: 15 additions & 1 deletion mocap/mocap.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def get_camera_matrix(camera_num):
visualizer.extrinsic2pyramid(extrinsic, 'c', 0.2)
visualizer.show()

chosen_rt = 0

image_points = np.array([[[159, 96], [166, 90]],[[161, 104], [171, 99]],[[162, 108], [172, 104]],[[162, 113], [172, 111]],[[163, 118], [172, 117]],[[164, 121], [172, 122]],[[165, 127], [173, 130]],[[165, 134], [173, 140]],[[166, 142], [174, 150]],[[167, 150], [175, 162]],[[167, 158], [175, 172]],[[168, 166], [176, 182]],[[168, 173], [175, 194]],[[167, 181], [175, 203]],[[167, 185], [175, 209]],[[167, 191], [174, 219]],[[167, 199], [173, 228]],[[166, 205], [172, 237]],[[166, 211], [171, 244]],[[165, 216], [170, 250]],[[165, 219], [169, 255]],[[164, 221], [169, 258]],[[163, 221], [169, 259]],[[164, 220], [170, 256]],[[164, 216], [171, 252]],[[165, 211], [172, 244]],[[165, 205], [172, 237]],[[164, 201], [172, 232]],[[164, 195], [172, 224]],[[164, 190], [171, 215]],[[163, 184], [170, 208]],[[161, 178], [167, 200]],[[159, 173], [164, 192]],[[157, 168], [160, 184]],[[154, 163], [155, 178]],[[152, 162], [153, 175]],[[150, 159], [148, 171]],[[147, 158], [144, 170]],[[145, 159], [140, 170]],[[143, 161], [137, 174]],[[142, 166], [135, 179]],[[142, 169], [134, 182]],[[142, 175], [133, 188]],[[141, 180], [131, 195]],[[141, 186], [130, 203]],[[140, 193], [129, 209]],[[139, 199], [127, 215]],[[138, 205], [126, 222]],[[137, 210], [124, 229]],[[135, 214], [123, 231]],[[133, 217], [120, 234]],[[130, 218], [116, 234]],[[126, 216], [112, 231]],[[123, 213], [109, 226]],[[120, 208], [105, 218]],[[119, 203], [103, 214]],[[117, 197], [101, 207]],[[115, 190], [100, 198]],[[114, 182], [99, 191]],[[113, 175], [100, 184]],[[113, 170], [101, 178]],[[113, 166], [102, 174]],[[113, 164], [103, 173]],[[114, 164], [103, 173]],[[114, 167], [104, 176]],[[115, 172], [104, 181]],[[116, 177], [103, 186]],[[117, 184], [103, 194]],[[117, 189], [102, 198]],[[117, 196], [101, 205]],[[115, 202], [99, 213]],[[112, 210], [96, 219]],[[110, 215], [94, 223]],[[106, 218], [91, 225]],[[104, 219], [90, 225]],[[109, 146], [102, 155]],[[112, 145], [99, 154]],[[113, 146], [101, 154]],[[114, 145], [101, 154]],[[114, 144], [102, 153]],[[114, 144], [101, 153]],[[114, 145], [101, 154]],[[114, 147], [102, 156]],[[113, 150], [102, 158]]
])
Expand Down Expand Up @@ -135,6 +134,21 @@ def DLT(P1, P2, point1, point2):

return object_points

chosen_rt = None
max_points_infront_of_camera = 0
for i in range(0, 4):
object_points = triangulate_points(points[:100], np.eye(3), np.zeros(3, dtype=np.float32), Rs[i], ts[i])
object_points_camera_2_coordinate_frame = np.array([Rs[i].T @ object_point for object_point in object_points])

points_infront_of_camera = np.sum(object_points[:,2] > 0) + np.sum(object_points_camera_2_coordinate_frame[:,2] > 0)
print(points_infront_of_camera)

if points_infront_of_camera > max_points_infront_of_camera:
max_points_infront_of_camera = points_infront_of_camera
chosen_rt = i

print(chosen_rt)

def visualize(image_points, object_points, r1, t1, r2, t2):
visualizer2 = CameraPoseVisualizer([-1, 1], [-1, 1], [0, 2])
extrinsic1 = np.r_[np.c_[r1, t1], [[0,0,0,1]]]
Expand Down
18 changes: 18 additions & 0 deletions new_app/vite-project/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
24 changes: 24 additions & 0 deletions new_app/vite-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
27 changes: 27 additions & 0 deletions new_app/vite-project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
37 changes: 37 additions & 0 deletions new_app/vite-project/api/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
class Singleton:
"""
A non-thread-safe helper class to ease implementing singletons.
This should be used as a decorator -- not a metaclass -- to the
class that should be a singleton.
The decorated class can define one `__init__` function that
takes only the `self` argument. Also, the decorated class cannot be
inherited from. Other than that, there are no restrictions that apply
to the decorated class.
To get the singleton instance, use the `instance` method. Trying
to use `__call__` will result in a `TypeError` being raised.
"""

def __init__(self, decorated):
self._decorated = decorated

def instance(self):
"""
Returns the singleton instance. Upon its first call, it creates a
new instance of the decorated class and calls its `__init__` method.
On all subsequent calls, the already created instance is returned.
"""
try:
return self._instance
except AttributeError:
self._instance = self._decorated()
return self._instance

def __call__(self):
raise TypeError('Singletons must be accessed through `instance()`.')

def __instancecheck__(self, inst):
return isinstance(inst, self._decorated)
12 changes: 12 additions & 0 deletions new_app/vite-project/api/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from flask import Flask, render_template
from flask_socketio import SocketIO

app = Flask(__name__)
socketio = SocketIO(app, path="/api/socket.io/")

@app.route("/api")
def test():
return '<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js" integrity="sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==" crossorigin="anonymous"></script><script type="text/javascript" charset="utf-8">var socket = io(\'http://localhost:3000\', {path: \'/api/socket.io/\'});socket.on(\'connect\', function() {socket.emit(\'my event\', {data: \'I\m connected!\'});});</script>', 200

if __name__ == '__main__':
socketio.run(app, port=3001, debug=True)
Loading

0 comments on commit 9d8bea1

Please sign in to comment.