sciveo 0.1.75__tar.gz → 0.1.76__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sciveo-0.1.75 → sciveo-0.1.76}/PKG-INFO +1 -1
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/db/read_table.py +4 -17
- sciveo-0.1.76/sciveo/media/capture/games/asteroids/asteroid.py +34 -0
- sciveo-0.1.76/sciveo/media/capture/games/asteroids/base_move.py +26 -0
- sciveo-0.1.76/sciveo/media/capture/games/asteroids/circle.py +31 -0
- sciveo-0.1.76/sciveo/media/capture/games/asteroids/game.py +11 -0
- sciveo-0.1.76/sciveo/media/capture/games/asteroids/geometrics.py +36 -0
- sciveo-0.1.76/sciveo/media/capture/games/asteroids/gravity_ball.py +32 -0
- sciveo-0.1.76/sciveo/media/capture/games/asteroids/laser.py +42 -0
- sciveo-0.1.76/sciveo/media/capture/games/asteroids/rocket.py +160 -0
- sciveo-0.1.76/sciveo/media/capture/games/asteroids/space_asteroids.py +155 -0
- sciveo-0.1.76/sciveo/media/capture/games/asteroids/volume_bar.py +24 -0
- sciveo-0.1.76/sciveo/tools/draw/__init__.py +0 -0
- sciveo-0.1.76/sciveo/version.py +2 -0
- sciveo-0.1.76/sciveo/web/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo.egg-info/PKG-INFO +1 -1
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo.egg-info/SOURCES.txt +12 -0
- sciveo-0.1.75/sciveo/version.py +0 -2
- {sciveo-0.1.75 → sciveo-0.1.76}/README.md +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/api/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/api/base.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/api/predictors.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/api/server.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/api/upload.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/cli.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/common/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/common/configuration.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/common/model.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/common/optimizers.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/common/sampling.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/content/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/content/dataset.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/content/experiment.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/content/project.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/content/runner.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/db/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/capture/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/capture/cam.py +0 -0
- {sciveo-0.1.75/sciveo/media/ml → sciveo-0.1.76/sciveo/media/capture/games}/__init__.py +0 -0
- {sciveo-0.1.75/sciveo/media/ml/encoders → sciveo-0.1.76/sciveo/media/capture/games/asteroids}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/capture/gst_server.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/capture/motion_detection.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/capture/nvr.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/capture/readers.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/capture/rtsp.py +0 -0
- {sciveo-0.1.75/sciveo/media/ml/nlp → sciveo-0.1.76/sciveo/media/ml}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/ml/base.py +0 -0
- {sciveo-0.1.75/sciveo/media/ml/time_series → sciveo-0.1.76/sciveo/media/ml/encoders}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/ml/encoders/base.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/ml/encoders/normalizer.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines → sciveo-0.1.76/sciveo/media/ml/nlp}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/ml/nlp/search.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines/layouts → sciveo-0.1.76/sciveo/media/ml/time_series}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/ml/time_series/dataset.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/ml/time_series/predictor.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/ml/time_series/trainer.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/ml/time_series/window_generator.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines/postprocessors → sciveo-0.1.76/sciveo/media/pipelines}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/base.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/job_daemon.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines/processors → sciveo-0.1.76/sciveo/media/pipelines/layouts}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/layouts/base.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/pipeline.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines/processors/audio → sciveo-0.1.76/sciveo/media/pipelines/postprocessors}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/postprocessors/base.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/postprocessors/default.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines/processors/file → sciveo-0.1.76/sciveo/media/pipelines/processors}/__init__.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines/processors/image → sciveo-0.1.76/sciveo/media/pipelines/processors/audio}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/audio/audio.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/audio/audio_extractor_process.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/aws.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/base.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines/processors/nlp → sciveo-0.1.76/sciveo/media/pipelines/processors/file}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/file/archive.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines/processors/sci → sciveo-0.1.76/sciveo/media/pipelines/processors/image}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/album.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/album_in_image.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/depth_esimation.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/embeddings.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/filters.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/generators.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/histogram.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/mask.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/object_detection.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/resize.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/segmentation.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/image/watermark.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/media_info.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines/processors/sci/time_series → sciveo-0.1.76/sciveo/media/pipelines/processors/nlp}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/nlp/address.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/qr.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines/processors/video → sciveo-0.1.76/sciveo/media/pipelines/processors/sci}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/sci/base.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/sci/dataset.py +0 -0
- {sciveo-0.1.75/sciveo/media/pipelines/web → sciveo-0.1.76/sciveo/media/pipelines/processors/sci/time_series}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/sci/time_series/predictor.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/sci/time_series/trainer.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/tpu_base.py +0 -0
- {sciveo-0.1.75/sciveo/media/tools → sciveo-0.1.76/sciveo/media/pipelines/processors/video}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/video/generators.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/video/motion_detection.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/video/resize.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/video/video_album.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/video/video_frames.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/processors/video/video_resample.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/queues.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/server.py +0 -0
- {sciveo-0.1.75/sciveo/ml → sciveo-0.1.76/sciveo/media/pipelines/web}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/pipelines/web/server.py +0 -0
- {sciveo-0.1.75/sciveo/ml/dataset → sciveo-0.1.76/sciveo/media/tools}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/media/tools/video_interactive.py +0 -0
- {sciveo-0.1.75/sciveo/ml/evaluation → sciveo-0.1.76/sciveo/ml}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/base.py +0 -0
- {sciveo-0.1.75/sciveo/ml/images → sciveo-0.1.76/sciveo/ml/dataset}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/dataset/object_detection.py +0 -0
- {sciveo-0.1.75/sciveo/ml/nlp → sciveo-0.1.76/sciveo/ml/evaluation}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/evaluation/markdown.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/evaluation/object_detection.py +0 -0
- {sciveo-0.1.75/sciveo/ml/nlp/tokenizers → sciveo-0.1.76/sciveo/ml/images}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/images/base.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/images/description.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/images/embeddings.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/images/object_detection.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/images/tools.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/images/transformers.py +0 -0
- {sciveo-0.1.75/sciveo/ml/video → sciveo-0.1.76/sciveo/ml/nlp}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/nlp/embeddings.py +0 -0
- {sciveo-0.1.75/sciveo/monitoring → sciveo-0.1.76/sciveo/ml/nlp/tokenizers}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/nlp/tokenizers/bpe.py +0 -0
- {sciveo-0.1.75/sciveo/monitoring/power → sciveo-0.1.76/sciveo/ml/video}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/ml/video/description.py +0 -0
- {sciveo-0.1.75/sciveo/monitoring/watchdog → sciveo-0.1.76/sciveo/monitoring}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/monitoring/monitor.py +0 -0
- {sciveo-0.1.75/sciveo/network → sciveo-0.1.76/sciveo/monitoring/power}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/monitoring/power/ems300.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/monitoring/power/sim.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/monitoring/power/tools.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/monitoring/start.py +0 -0
- {sciveo-0.1.75/sciveo/tools → sciveo-0.1.76/sciveo/monitoring/watchdog}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/monitoring/watchdog/base.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/monitoring/watchdog/process.py +0 -0
- {sciveo-0.1.75/sciveo/tools/aws → sciveo-0.1.76/sciveo/network}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/network/camera.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/network/sniffer.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/network/tools.py +0 -0
- {sciveo-0.1.75/sciveo/tools/draw → sciveo-0.1.76/sciveo/tools}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/array.py +0 -0
- {sciveo-0.1.75/sciveo/web → sciveo-0.1.76/sciveo/tools/aws}/__init__.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/aws/priority_queue.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/aws/s3.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/common.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/complexity.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/compress.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/configuration.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/crypto.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/daemon.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/draw/contours.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/formating.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/hardware.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/http.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/logger.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/os.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/queue.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/random.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/remote.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/simple_counter.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/synchronized.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/timers.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/tools/totp.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo/web/common.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo.egg-info/dependency_links.txt +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo.egg-info/entry_points.txt +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo.egg-info/requires.txt +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/sciveo.egg-info/top_level.txt +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/setup.cfg +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/setup.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/test/test_complexity.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/test/test_compress.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/test/test_configuration.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/test/test_crypto.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/test/test_eval_markdown.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/test/test_ml_datasets.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/test/test_monitoring.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/test/test_runner.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/test/test_sampling.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/test/test_tokenizers.py +0 -0
- {sciveo-0.1.75 → sciveo-0.1.76}/test/test_totp.py +0 -0
|
@@ -158,6 +158,10 @@ class BaseTable:
|
|
|
158
158
|
return df_new
|
|
159
159
|
|
|
160
160
|
def save(self, file_path=None):
|
|
161
|
+
if self.latest_df.empty:
|
|
162
|
+
info("Empty", self.latest_df)
|
|
163
|
+
return
|
|
164
|
+
|
|
161
165
|
if self.save_path is not None and self.last_id is not None:
|
|
162
166
|
from_id = int(self.latest_df[self.id_col].min())
|
|
163
167
|
to_id = int(self.latest_df[self.id_col].max())
|
|
@@ -185,20 +189,3 @@ class BaseTable:
|
|
|
185
189
|
|
|
186
190
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
187
191
|
self.close()
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if __name__ == "__main__":
|
|
191
|
-
with BaseTable("video_record_predictions", batch_size=10_000, save_path="/home/ml/video_predictions/data") as T:
|
|
192
|
-
|
|
193
|
-
T.update(last_id=1_000_000)
|
|
194
|
-
T.load()
|
|
195
|
-
if not T.df.empty:
|
|
196
|
-
debug(T.df.columns)
|
|
197
|
-
debug(T.df[["key", "people", "is_valid", "updated_at", "data"]].head())
|
|
198
|
-
|
|
199
|
-
while(True):
|
|
200
|
-
df = T.update()
|
|
201
|
-
if df.empty:
|
|
202
|
-
info("Finished", T.df.shape)
|
|
203
|
-
break
|
|
204
|
-
info("read", df.shape, df[["key", "people"]].head())
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import cv2
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from geometrics import *
|
|
6
|
+
from base_move import *
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Asteroid(BaseMoveConstantVelocity):
|
|
10
|
+
def __init__(self, x0, y0, vx0, vy0, r0, color=(255, 0, 0), size_contour=20):
|
|
11
|
+
super().__init__(x0, y0, vx0, vy0, color)
|
|
12
|
+
|
|
13
|
+
self.r0 = r0
|
|
14
|
+
self.r = r0
|
|
15
|
+
self.size_contour = size_contour
|
|
16
|
+
|
|
17
|
+
self.generate_contour()
|
|
18
|
+
|
|
19
|
+
def draw(self, frame):
|
|
20
|
+
# self.generate_contour()
|
|
21
|
+
list_points = []
|
|
22
|
+
for p in self.list_points:
|
|
23
|
+
list_points.append((int(self.x + p[0]), int(self.y + p[1])))
|
|
24
|
+
cv2.drawContours(frame, [np.array(list_points)], 0, self.color, 1)
|
|
25
|
+
cv2.circle(frame, (int(self.x), int(self.y)), int(self.r), (0, 0, 200), thickness=1)
|
|
26
|
+
|
|
27
|
+
def generate_contour(self):
|
|
28
|
+
self.list_points = []
|
|
29
|
+
for i in range(self.size_contour):
|
|
30
|
+
r = self.r0 * np.sqrt(np.random.uniform(0.3, 1.0))
|
|
31
|
+
# angle = np.random.uniform() * 2 * PI
|
|
32
|
+
angle = i * 2 * PI / self.size_contour
|
|
33
|
+
p = (r * math.cos(angle), r * math.sin(angle))
|
|
34
|
+
self.list_points.append(p)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
from geometrics import *
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BaseMoveConstantVelocity:
|
|
7
|
+
def __init__(self, x0, y0, vx0, vy0, color=(0, 0, 255)):
|
|
8
|
+
self.x = x0
|
|
9
|
+
self.y = y0
|
|
10
|
+
self.vx = vx0
|
|
11
|
+
self.vy = vy0
|
|
12
|
+
self.color = color
|
|
13
|
+
|
|
14
|
+
def move(self, frame):
|
|
15
|
+
w = frame.shape[1]
|
|
16
|
+
h = frame.shape[0]
|
|
17
|
+
|
|
18
|
+
self.x += self.vx
|
|
19
|
+
self.y += self.vy
|
|
20
|
+
|
|
21
|
+
self.x, self.y = frame_bounds_rewind(w, h, self.x, self.y)
|
|
22
|
+
|
|
23
|
+
self.draw(frame)
|
|
24
|
+
|
|
25
|
+
def draw(self, frame):
|
|
26
|
+
pass
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
from base_move import *
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Circle(BaseMoveConstantVelocity):
|
|
7
|
+
def __init__(self, x0, y0, r, vx0, vy0, color=(0, 0, 255)):
|
|
8
|
+
super().__init__(x0, y0, vx0, vy0, color)
|
|
9
|
+
self.r = r
|
|
10
|
+
|
|
11
|
+
def move(self, frame):
|
|
12
|
+
w = frame.shape[1]
|
|
13
|
+
h = frame.shape[0]
|
|
14
|
+
|
|
15
|
+
self.x += self.vx
|
|
16
|
+
self.y += self.vy
|
|
17
|
+
|
|
18
|
+
self.x, self.y = frame_bounds_rewind(w - self.r, h - self.r, self.x, self.y)
|
|
19
|
+
|
|
20
|
+
self.draw(frame)
|
|
21
|
+
|
|
22
|
+
def draw(self, frame):
|
|
23
|
+
angle = 0.0
|
|
24
|
+
while(angle <= 2 * math.pi):
|
|
25
|
+
x1 = self.x + self.r * math.cos(angle)
|
|
26
|
+
y1 = self.y + self.r * math.sin(angle)
|
|
27
|
+
x1 = int(x1)
|
|
28
|
+
y1 = int(y1)
|
|
29
|
+
angle += 0.01
|
|
30
|
+
|
|
31
|
+
frame[y1, x1] = self.color
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import cv2
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
PI = 3.141592653589793
|
|
6
|
+
|
|
7
|
+
def to_radians(angle):
|
|
8
|
+
return angle * PI / 180
|
|
9
|
+
|
|
10
|
+
def line_perpendicular(p1, p2, l):
|
|
11
|
+
x1, y1 = p1
|
|
12
|
+
x2, y2 = p2
|
|
13
|
+
|
|
14
|
+
x3 = x2 - x1
|
|
15
|
+
y3 = y2 - y1
|
|
16
|
+
|
|
17
|
+
mag = math.sqrt(x3 * x3 + y3 * y3)
|
|
18
|
+
x3 /= mag
|
|
19
|
+
y3 /= mag
|
|
20
|
+
|
|
21
|
+
x4 = x2 - y3 * l
|
|
22
|
+
y4 = y2 + x3 * l
|
|
23
|
+
x5 = x2 + y3 * l
|
|
24
|
+
y5 = y2 - x3 * l
|
|
25
|
+
return (int(x4), int(y4)), (int(x5), int(y5))
|
|
26
|
+
|
|
27
|
+
def frame_bounds_rewind(w, h, x, y):
|
|
28
|
+
if x > w:
|
|
29
|
+
x = 0
|
|
30
|
+
if x < 0:
|
|
31
|
+
x = w
|
|
32
|
+
if y > h:
|
|
33
|
+
y = 0
|
|
34
|
+
if y < 0:
|
|
35
|
+
y = h
|
|
36
|
+
return x, y
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import cv2
|
|
2
|
+
|
|
3
|
+
class GravityBall:
|
|
4
|
+
def __init__(self, r, x=0, y=0, gx=0.2, gy=0.1, color=(255, 0, 0)):
|
|
5
|
+
self.color = color
|
|
6
|
+
self.r = r
|
|
7
|
+
|
|
8
|
+
self.x = 0
|
|
9
|
+
self.y = 0
|
|
10
|
+
|
|
11
|
+
self.vx = 0
|
|
12
|
+
self.vy = 0
|
|
13
|
+
self.gx = gx
|
|
14
|
+
self.gy = gy
|
|
15
|
+
|
|
16
|
+
def move(self, frame):
|
|
17
|
+
w = frame.shape[1]
|
|
18
|
+
h = frame.shape[0]
|
|
19
|
+
|
|
20
|
+
self.vx += self.gx
|
|
21
|
+
self.vy += self.gy
|
|
22
|
+
self.x += self.vx
|
|
23
|
+
self.y += self.vy
|
|
24
|
+
|
|
25
|
+
if self.x + self.r >= w:
|
|
26
|
+
self.x = w - self.r
|
|
27
|
+
self.vx = - self.vx
|
|
28
|
+
if self.y + self.r >= h:
|
|
29
|
+
self.y = h - self.r
|
|
30
|
+
self.vy = - self.vy
|
|
31
|
+
|
|
32
|
+
cv2.circle(frame, (int(self.x), int(self.y)), self.r, self.color, thickness=-1)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import cv2
|
|
2
|
+
import math
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from geometrics import to_radians
|
|
6
|
+
from base_move import *
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Laser(BaseMoveConstantVelocity):
|
|
10
|
+
def __init__(self, x0, y0, angle):
|
|
11
|
+
super().__init__(x0, y0, 0, 0, (0, 0, 255))
|
|
12
|
+
# self.path = 0
|
|
13
|
+
# self.x0 = x0
|
|
14
|
+
# self.y0 = y0
|
|
15
|
+
|
|
16
|
+
self.l = 10
|
|
17
|
+
self.angle = angle
|
|
18
|
+
|
|
19
|
+
self.points()
|
|
20
|
+
|
|
21
|
+
self.v = 2.5
|
|
22
|
+
self.vx = self.v * math.cos(to_radians(self.angle))
|
|
23
|
+
self.vy = self.v * math.sin(to_radians(self.angle))
|
|
24
|
+
|
|
25
|
+
def points(self):
|
|
26
|
+
angle = to_radians(self.angle)
|
|
27
|
+
self.p1 = (int(self.x), int(self.y))
|
|
28
|
+
self.p2 = (int(self.x + self.l * math.cos(angle)), int(self.y + self.l * math.sin(angle)))
|
|
29
|
+
# self.path = math.sqrt((self.x - self.x0) ** 2 + (self.y - self.y0) ** 2)
|
|
30
|
+
|
|
31
|
+
def move(self, frame):
|
|
32
|
+
w = frame.shape[1]
|
|
33
|
+
h = frame.shape[0]
|
|
34
|
+
|
|
35
|
+
self.x += self.vx
|
|
36
|
+
self.y += self.vy
|
|
37
|
+
|
|
38
|
+
self.points()
|
|
39
|
+
|
|
40
|
+
cv2.line(frame, self.p1, self.p2, self.color, 2)
|
|
41
|
+
|
|
42
|
+
return self.x >= 0 and self.x <= w and self.y >= 0 and self.y <= h
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import cv2
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from geometrics import *
|
|
6
|
+
from laser import *
|
|
7
|
+
from volume_bar import *
|
|
8
|
+
from base_move import *
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class RocketBase(BaseMoveConstantVelocity):
|
|
12
|
+
def __init__(self, x0, y0):
|
|
13
|
+
super().__init__(x0, y0, 0, 0, (255, 0, 0))
|
|
14
|
+
self.l = 10000000000
|
|
15
|
+
self.angle = 0
|
|
16
|
+
|
|
17
|
+
def check_collision(self, x, y, r):
|
|
18
|
+
return False
|
|
19
|
+
|
|
20
|
+
def rotate(self, angle):
|
|
21
|
+
self.angle += angle
|
|
22
|
+
|
|
23
|
+
def accelerate(self, a):
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
def fire(self):
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
def alive(self):
|
|
30
|
+
return True
|
|
31
|
+
|
|
32
|
+
def laser_positions(self):
|
|
33
|
+
return []
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class SimpleRocket(RocketBase):
|
|
37
|
+
def __init__(self, x0=0, y0=0, color=(255, 0, 0)):
|
|
38
|
+
super().__init__(x0, y0)
|
|
39
|
+
self.color = color
|
|
40
|
+
self.r = 10
|
|
41
|
+
|
|
42
|
+
self.vx = 0
|
|
43
|
+
self.vy = 0
|
|
44
|
+
|
|
45
|
+
def accelerate(self, gx, gy):
|
|
46
|
+
self.vx += gx
|
|
47
|
+
self.vy += gy
|
|
48
|
+
|
|
49
|
+
def draw(self, frame):
|
|
50
|
+
cv2.circle(frame, (int(self.x), int(self.y)), self.r, self.color, thickness=-1)
|
|
51
|
+
cv2.putText(frame, "V ({},{})".format(round(self.vx, 2), round(self.vy, 2)), (5, 20), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=0.5, color=(255, 255, 255), thickness=1)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class Rocket(RocketBase):
|
|
55
|
+
def __init__(self, x0=0, y0=0, color=(255, 0, 0), txt_pos=(5, 20), l=10, laser_count=100, fuel=20):
|
|
56
|
+
super().__init__(x0, y0)
|
|
57
|
+
self.color = color
|
|
58
|
+
self.txt_pos = txt_pos
|
|
59
|
+
self.l = l
|
|
60
|
+
|
|
61
|
+
self.thruster_default = 30
|
|
62
|
+
self.thruster = 0
|
|
63
|
+
self.fuel = fuel
|
|
64
|
+
|
|
65
|
+
self.a = 0
|
|
66
|
+
self.ax = 0
|
|
67
|
+
self.ay = 0
|
|
68
|
+
|
|
69
|
+
self.vx = 0
|
|
70
|
+
self.vy = 0
|
|
71
|
+
|
|
72
|
+
self.laser_count = laser_count
|
|
73
|
+
self.lasers = []
|
|
74
|
+
|
|
75
|
+
self.fuel_bar = VolumeBar((400, 20), self.fuel, name="FUEL", color=(255, 0, 0))
|
|
76
|
+
self.laser_bar = VolumeBar((400, 50), self.laser_count, name="LASER", color=(0, 0, 255))
|
|
77
|
+
|
|
78
|
+
def accelerate(self, a):
|
|
79
|
+
if self.fuel < a:
|
|
80
|
+
a = self.fuel
|
|
81
|
+
self.fuel -= a
|
|
82
|
+
|
|
83
|
+
angle = to_radians(self.angle)
|
|
84
|
+
self.ax = a * math.cos(angle)
|
|
85
|
+
self.ay = a * math.sin(angle)
|
|
86
|
+
self.a = a
|
|
87
|
+
|
|
88
|
+
self.vx += self.ax
|
|
89
|
+
self.vy += self.ay
|
|
90
|
+
|
|
91
|
+
self.thruster = self.thruster_default
|
|
92
|
+
|
|
93
|
+
def draw(self, frame):
|
|
94
|
+
angle = to_radians(self.angle)
|
|
95
|
+
p0 = (int(self.x), int(self.y))
|
|
96
|
+
p1 = (int(self.x + self.l * math.cos(angle)), int(self.y + self.l * math.sin(angle)))
|
|
97
|
+
p2 = (int(self.x - self.l * math.cos(angle)), int(self.y - self.l * math.sin(angle)))
|
|
98
|
+
p3, p4 = line_perpendicular(p1, p2, self.l)
|
|
99
|
+
|
|
100
|
+
cv2.line(frame, p1, p2, self.color, 2)
|
|
101
|
+
# cv2.line(frame, p3, p4, self.color, 4)
|
|
102
|
+
cv2.line(frame, p3, p1, (0, 0, 255), 3)
|
|
103
|
+
cv2.line(frame, p4, p1, (0, 255, 0), 3)
|
|
104
|
+
cv2.line(frame, p3, p0, self.color, 2)
|
|
105
|
+
cv2.line(frame, p4, p0, self.color, 2)
|
|
106
|
+
|
|
107
|
+
if self.thruster > 0:
|
|
108
|
+
l = self.a * 200
|
|
109
|
+
p1 = p2
|
|
110
|
+
da = 0.3
|
|
111
|
+
p2 = [int(p1[0] - l * math.cos(angle - da)), int(p1[1] - l * math.sin(angle - da))]
|
|
112
|
+
p3 = [int(p1[0] - l * math.cos(angle + da)), int(p1[1] - l * math.sin(angle + da))]
|
|
113
|
+
cv2.drawContours(frame, [np.array([p1, p2, p3])], 0, (0, 0, 255), -1)
|
|
114
|
+
self.thruster -= 1
|
|
115
|
+
|
|
116
|
+
txt = "V ({},{}) A[{}]".format(round(self.vx, 3), round(self.vy, 3), self.angle)
|
|
117
|
+
cv2.putText(frame, txt, self.txt_pos, fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=0.3, color=(255, 255, 255), thickness=1)
|
|
118
|
+
|
|
119
|
+
self.move_lasers(frame)
|
|
120
|
+
|
|
121
|
+
self.fuel_bar(frame, self.fuel)
|
|
122
|
+
self.laser_bar(frame, self.laser_count)
|
|
123
|
+
|
|
124
|
+
def move_lasers(self, frame):
|
|
125
|
+
for laser in self.lasers:
|
|
126
|
+
if not laser.move(frame):
|
|
127
|
+
self.lasers.remove(laser)
|
|
128
|
+
|
|
129
|
+
def fire(self):
|
|
130
|
+
if self.laser_count > 0:
|
|
131
|
+
self.laser_count -= 1
|
|
132
|
+
self.lasers.append(Laser(self.x, self.y, self.angle))
|
|
133
|
+
|
|
134
|
+
def laser_positions(self):
|
|
135
|
+
positions = []
|
|
136
|
+
for laser in self.lasers:
|
|
137
|
+
positions.append([laser.p1, laser.p2, laser.angle])
|
|
138
|
+
return positions
|
|
139
|
+
|
|
140
|
+
def remove_laser(self, idx):
|
|
141
|
+
if idx < len(self.lasers):
|
|
142
|
+
del self.lasers[idx]
|
|
143
|
+
|
|
144
|
+
def check_collision(self, x, y, r):
|
|
145
|
+
# d = np.linalg.norm(np.array([x, y]) - np.array([self.x, self.y]))
|
|
146
|
+
d = math.sqrt((x - self.x) ** 2 + (y - self.y) ** 2)
|
|
147
|
+
return d < r + self.l
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class RocketExplosion(RocketBase):
|
|
151
|
+
def __init__(self, x0, y0):
|
|
152
|
+
super().__init__(x0, y0)
|
|
153
|
+
self.r = 3
|
|
154
|
+
|
|
155
|
+
def move(self, frame):
|
|
156
|
+
cv2.circle(frame, (int(self.x), int(self.y)), int(self.r), (0, 0, 255), thickness=-1)
|
|
157
|
+
self.r += 0.8
|
|
158
|
+
|
|
159
|
+
def alive(self):
|
|
160
|
+
return self.r < 100
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import cv2
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from rocket import *
|
|
5
|
+
from asteroid import *
|
|
6
|
+
from volume_bar import *
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SpaceAsteroids:
|
|
10
|
+
def __init__(self, w, h, rocket_lives=10):
|
|
11
|
+
self.W = w
|
|
12
|
+
self.H = h
|
|
13
|
+
self.rocket_lives = rocket_lives
|
|
14
|
+
|
|
15
|
+
self.rocket = Rocket(x0=50, y0=50, color=(255, 255, 0), txt_pos=(5, 30), laser_count=200)
|
|
16
|
+
self.rocket_lives_bar = VolumeBar((200, 20), self.rocket_lives, name="LIVE", color=(0, 255, 0))
|
|
17
|
+
|
|
18
|
+
self.asteroids_removed = 0
|
|
19
|
+
self.asteroids = []
|
|
20
|
+
self.init_asteroids()
|
|
21
|
+
self.asteroids_bar = VolumeBar((200, 40), len(self.asteroids) * 2, name="ASTEROIDS", color=(0, 255, 255))
|
|
22
|
+
|
|
23
|
+
def init_asteroids(self):
|
|
24
|
+
dv = 1.1
|
|
25
|
+
while(len(self.asteroids) < 30):
|
|
26
|
+
x0 = np.random.randint(200, self.W)
|
|
27
|
+
y0 = np.random.randint(200, self.H)
|
|
28
|
+
r0 = np.random.randint(5, 100)
|
|
29
|
+
is_usable = True
|
|
30
|
+
for asteroid in self.asteroids:
|
|
31
|
+
d = math.sqrt((asteroid.x - x0) ** 2 + (asteroid.y - y0) ** 2)
|
|
32
|
+
if d < (asteroid.r + r0) * 1.2:
|
|
33
|
+
is_usable = False
|
|
34
|
+
break
|
|
35
|
+
|
|
36
|
+
if is_usable:
|
|
37
|
+
self.asteroids.append(
|
|
38
|
+
Asteroid(
|
|
39
|
+
x0, y0,
|
|
40
|
+
np.random.uniform(-dv, dv),
|
|
41
|
+
np.random.uniform(-dv, dv),
|
|
42
|
+
r0,
|
|
43
|
+
color=(255, 255, 255),
|
|
44
|
+
size_contour=10
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def run(self):
|
|
49
|
+
vrotate = 0
|
|
50
|
+
|
|
51
|
+
while(True):
|
|
52
|
+
k = cv2.waitKey(1)
|
|
53
|
+
if k == 27: # Esc key to stop
|
|
54
|
+
break
|
|
55
|
+
|
|
56
|
+
if k == ord('u'):
|
|
57
|
+
self.rocket.accelerate(0.1)
|
|
58
|
+
if k == ord('i'):
|
|
59
|
+
self.rocket.accelerate(0.2)
|
|
60
|
+
if k == ord('o'):
|
|
61
|
+
self.rocket.accelerate(0.3)
|
|
62
|
+
if k == ord('m'):
|
|
63
|
+
self.rocket.fire()
|
|
64
|
+
if k == ord('j'):
|
|
65
|
+
vrotate = -2
|
|
66
|
+
if k == ord('k'):
|
|
67
|
+
vrotate = 0
|
|
68
|
+
if k == ord('l'):
|
|
69
|
+
vrotate = 2
|
|
70
|
+
|
|
71
|
+
self.rocket.rotate(vrotate)
|
|
72
|
+
|
|
73
|
+
frame = np.zeros(shape=[self.H, self.W, 3], dtype=np.uint8)
|
|
74
|
+
|
|
75
|
+
self.rocket.move(frame)
|
|
76
|
+
|
|
77
|
+
for asteroid in self.asteroids:
|
|
78
|
+
asteroid.move(frame)
|
|
79
|
+
|
|
80
|
+
for i in range(len(self.asteroids)):
|
|
81
|
+
for j in range(i + 1, len(self.asteroids)):
|
|
82
|
+
d = math.sqrt((self.asteroids[i].x - self.asteroids[j].x) ** 2 + (self.asteroids[i].y - self.asteroids[j].y) ** 2)
|
|
83
|
+
if d < self.asteroids[i].r + self.asteroids[j].r:
|
|
84
|
+
vx1 = ((self.asteroids[i].r - self.asteroids[j].r) * self.asteroids[i].vx + 2 * self.asteroids[j].r * self.asteroids[j].vx) / (self.asteroids[i].r + self.asteroids[j].r)
|
|
85
|
+
vy1 = ((self.asteroids[i].r - self.asteroids[j].r) * self.asteroids[i].vy + 2 * self.asteroids[j].r * self.asteroids[j].vy) / (self.asteroids[i].r + self.asteroids[j].r)
|
|
86
|
+
vx2 = ((self.asteroids[j].r - self.asteroids[i].r) * self.asteroids[j].vx + 2 * self.asteroids[i].r * self.asteroids[i].vx) / (self.asteroids[i].r + self.asteroids[j].r)
|
|
87
|
+
vy2 = ((self.asteroids[j].r - self.asteroids[i].r) * self.asteroids[j].vy + 2 * self.asteroids[i].r * self.asteroids[i].vy) / (self.asteroids[i].r + self.asteroids[j].r)
|
|
88
|
+
self.asteroids[i].vx = vx1
|
|
89
|
+
self.asteroids[i].vy = vy1
|
|
90
|
+
self.asteroids[j].vx = vx2
|
|
91
|
+
self.asteroids[j].vy = vy2
|
|
92
|
+
|
|
93
|
+
laser_positions = self.rocket.laser_positions()
|
|
94
|
+
for asteroid in self.asteroids:
|
|
95
|
+
for i, laser in enumerate(laser_positions):
|
|
96
|
+
d1 = math.sqrt((asteroid.x - laser[0][0]) ** 2 + (asteroid.y - laser[0][1]) ** 2)
|
|
97
|
+
d2 = math.sqrt((asteroid.x - laser[1][0]) ** 2 + (asteroid.y - laser[1][1]) ** 2)
|
|
98
|
+
if d1 < asteroid.r or d2 < asteroid.r:
|
|
99
|
+
self.asteroids.remove(asteroid)
|
|
100
|
+
self.rocket.remove_laser(i)
|
|
101
|
+
self.asteroids_removed += 1
|
|
102
|
+
|
|
103
|
+
if asteroid.r > 10:
|
|
104
|
+
angle1 = to_radians(laser[2] + 90)
|
|
105
|
+
angle2 = to_radians(laser[2] - 90)
|
|
106
|
+
self.asteroids.append(
|
|
107
|
+
Asteroid(
|
|
108
|
+
asteroid.x + math.cos(angle1) * (asteroid.r / 1.9),
|
|
109
|
+
asteroid.y + math.sin(angle1) * (asteroid.r / 1.9),
|
|
110
|
+
math.cos(angle1) * asteroid.vx,
|
|
111
|
+
math.sin(angle1) * asteroid.vy,
|
|
112
|
+
asteroid.r / 2,
|
|
113
|
+
color=(255, 255, 255),
|
|
114
|
+
size_contour=10
|
|
115
|
+
)
|
|
116
|
+
)
|
|
117
|
+
self.asteroids.append(
|
|
118
|
+
Asteroid(
|
|
119
|
+
asteroid.x + math.cos(angle2) * (asteroid.r / 1.9),
|
|
120
|
+
asteroid.y + math.sin(angle2) * (asteroid.r / 1.9),
|
|
121
|
+
math.cos(angle2) * asteroid.vx,
|
|
122
|
+
math.sin(angle2) * asteroid.vy,
|
|
123
|
+
asteroid.r / 2,
|
|
124
|
+
color=(255, 255, 255),
|
|
125
|
+
size_contour=10
|
|
126
|
+
)
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
break
|
|
130
|
+
|
|
131
|
+
for asteroid in self.asteroids:
|
|
132
|
+
if self.rocket.check_collision(asteroid.x, asteroid.y, asteroid.r):
|
|
133
|
+
self.asteroids.remove(asteroid)
|
|
134
|
+
self.rocket = RocketExplosion(self.rocket.x, self.rocket.y)
|
|
135
|
+
self.rocket_lives -= 1
|
|
136
|
+
break
|
|
137
|
+
|
|
138
|
+
if not self.rocket.alive():
|
|
139
|
+
if self.rocket_lives > 0:
|
|
140
|
+
self.rocket = Rocket(x0=self.rocket.x, y0=self.rocket.y, color=(255, 255, 0), txt_pos=(5, 30), laser_count=len(self.asteroids) * 10)
|
|
141
|
+
else:
|
|
142
|
+
break
|
|
143
|
+
|
|
144
|
+
if len(self.asteroids) == 0 and self.rocket_lives > 0:
|
|
145
|
+
self.rocket = Rocket(x0=400, y0=400, color=(255, 255, 0), txt_pos=(5, 30), l=50)
|
|
146
|
+
txt = "Winner"
|
|
147
|
+
self.rocket_lives = -1
|
|
148
|
+
else:
|
|
149
|
+
txt = "Asteroids {} / {}".format(self.asteroids_removed, len(self.asteroids))
|
|
150
|
+
cv2.putText(frame, txt, (5, 20), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=0.4, color=(255, 255, 255), thickness=1)
|
|
151
|
+
|
|
152
|
+
self.rocket_lives_bar(frame, self.rocket_lives)
|
|
153
|
+
self.asteroids_bar(frame, len(self.asteroids))
|
|
154
|
+
|
|
155
|
+
cv2.imshow('asteroids', frame)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import cv2
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class VolumeBar:
|
|
6
|
+
def __init__(self, p1, max_vol, name, color):
|
|
7
|
+
self.w = 100
|
|
8
|
+
self.h = 10
|
|
9
|
+
self.p1 = p1
|
|
10
|
+
self.max_vol = max_vol
|
|
11
|
+
self.name = name
|
|
12
|
+
self.color = color
|
|
13
|
+
|
|
14
|
+
self.p2 = [p1[0] + self.w, p1[1] + self.h]
|
|
15
|
+
|
|
16
|
+
def __call__(self, frame, vol):
|
|
17
|
+
self.draw(frame, vol)
|
|
18
|
+
|
|
19
|
+
def draw(self, frame, vol):
|
|
20
|
+
vol = min(self.max_vol, vol)
|
|
21
|
+
p3 = [int(self.p1[0] + self.w * vol / self.max_vol), self.p1[1] + self.h]
|
|
22
|
+
cv2.putText(frame, self.name, (self.p2[0] + 3, self.p2[1]), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=0.5, color=(255, 255, 255), thickness=1)
|
|
23
|
+
cv2.rectangle(frame, self.p1, p3, self.color, -1)
|
|
24
|
+
cv2.rectangle(frame, self.p1, self.p2, (255, 255, 255), 1)
|
|
File without changes
|
|
File without changes
|
|
@@ -34,6 +34,18 @@ sciveo/media/capture/motion_detection.py
|
|
|
34
34
|
sciveo/media/capture/nvr.py
|
|
35
35
|
sciveo/media/capture/readers.py
|
|
36
36
|
sciveo/media/capture/rtsp.py
|
|
37
|
+
sciveo/media/capture/games/__init__.py
|
|
38
|
+
sciveo/media/capture/games/asteroids/__init__.py
|
|
39
|
+
sciveo/media/capture/games/asteroids/asteroid.py
|
|
40
|
+
sciveo/media/capture/games/asteroids/base_move.py
|
|
41
|
+
sciveo/media/capture/games/asteroids/circle.py
|
|
42
|
+
sciveo/media/capture/games/asteroids/game.py
|
|
43
|
+
sciveo/media/capture/games/asteroids/geometrics.py
|
|
44
|
+
sciveo/media/capture/games/asteroids/gravity_ball.py
|
|
45
|
+
sciveo/media/capture/games/asteroids/laser.py
|
|
46
|
+
sciveo/media/capture/games/asteroids/rocket.py
|
|
47
|
+
sciveo/media/capture/games/asteroids/space_asteroids.py
|
|
48
|
+
sciveo/media/capture/games/asteroids/volume_bar.py
|
|
37
49
|
sciveo/media/ml/__init__.py
|
|
38
50
|
sciveo/media/ml/base.py
|
|
39
51
|
sciveo/media/ml/encoders/__init__.py
|
sciveo-0.1.75/sciveo/version.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|