Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #34

Merged
merged 11 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ python test.py
If you use arcjetCV in your research, please use the following BibTeX entries to cite it:

```BibTeX
@inbook{doi:10.2514/6.2023-1912,
author = {Alexandre Quintart and Magnus A. Haw},
title = {ArcjetCV: a new machine learning application for extracting time-resolved recession measurements from arc jet test videos},
booktitle = {AIAA SCITECH 2023 Forum},
doi = {10.2514/6.2023-1912},
URL = {https://arc.aiaa.org/doi/abs/10.2514/6.2023-1912},
eprint = {https://arc.aiaa.org/doi/pdf/10.2514/6.2023-1912},
@article{arcjetCV,
title={arcjetCV: an open-source software to analyze material ablation},
author={Quintart, Alexandre and Haw, Magnus and Semeraro, Federico},
journal={arXiv preprint arXiv:2404.11492},
year={2024}
}
```

Expand Down
Binary file not shown.
Binary file not shown.
968 changes: 508 additions & 460 deletions arcjetCV/segmentation/time/train_time.ipynb

Large diffs are not rendered by default.

Binary file modified docs/source/arcjet_video.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions docs/source/user_manual/user_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,3 @@ The **Analyze** tab contains tools for visualizing and fitting the processed edg

Export the plotted and fitted data to CSV using the "Export CSV/Plots" button.

.. figure:: /path/to/GUI3.png
:width: 70%
:align: center
:caption: The post-processing window.
Binary file modified tests/arcjet_test.mp4
Binary file not shown.
1 change: 0 additions & 1 deletion tests/test_10_150.json

This file was deleted.

24 changes: 12 additions & 12 deletions tests/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ def test_apply_crop(app, qtbot, mocker):
assert app.video is not None
assert app.videometa is not None

app.ui.spinBox_crop_xmin.setValue(117)
app.ui.spinBox_crop_xmax.setValue(391)
app.ui.spinBox_crop_ymin.setValue(36)
app.ui.spinBox_crop_ymax.setValue(641)
app.ui.spinBox_crop_xmin.setValue(100)
app.ui.spinBox_crop_xmax.setValue(425)
app.ui.spinBox_crop_ymin.setValue(10)
app.ui.spinBox_crop_ymax.setValue(700)

qtbot.mouseClick(app.ui.applyCrop, Qt.LeftButton)
expected_crop_settings = [[36, 641], [117, 391]]
expected_crop_settings = [[10, 700], [100, 425]]
current_crop_settings = app.videometa.crop_range()

assert (
Expand Down Expand Up @@ -236,11 +236,11 @@ def test_set_frame_range(app, qtbot, mocker):
Test setting the frame range for processing.
"""
test_load_video(app, qtbot, mocker)
app.ui.spinBox_FirstGoodFrame.setValue(10)
app.ui.spinBox_LastGoodFrame.setValue(150)
app.ui.spinBox_FirstGoodFrame.setValue(150)
app.ui.spinBox_LastGoodFrame.setValue(400)
app.process_all()
assert app.videometa["FIRST_GOOD_FRAME"] == 10
assert app.videometa["LAST_GOOD_FRAME"] == 150
assert app.videometa["FIRST_GOOD_FRAME"] == 150
assert app.videometa["LAST_GOOD_FRAME"] == 400


def test_process_every_nth_frame(app, qtbot, mocker):
Expand All @@ -260,7 +260,7 @@ def test_set_output_filename(app, qtbot, mocker):
test_load_video(app, qtbot, mocker)
app.ui.lineEdit_filename.setText("output_filename")
app.process_all()
assert app.processor.filename == "output_filename_10_150.json"
assert app.processor.filename == "output_filename_150_400.json"


def test_toggle_write_video(app, qtbot, mocker):
Expand Down Expand Up @@ -301,7 +301,7 @@ def test_load_analysis_files(app, qtbot, mocker):
"""
Test loading files in the 'Analysis' tab and verifying UI updates.
"""
expected_file_path = os.path.join(find_tests_path(), "test_10_150.json")
expected_file_path = os.path.join(find_tests_path(), "arcjet_test_150_400.json")
mocker.patch(
"PySide6.QtWidgets.QFileDialog.getOpenFileNames",
return_value=([expected_file_path], ""),
Expand All @@ -317,7 +317,7 @@ def test_plot_data_button(app, qtbot, mocker):
Test the 'Plot Data' button functionality in the 'Analysis' tab after loading analysis files.
"""

expected_file_path = os.path.join(find_tests_path(), "test_10_150.json")
expected_file_path = os.path.join(find_tests_path(), "arcjet_test_150_400.json")
mocker.patch(
"PySide6.QtWidgets.QFileDialog.getOpenFileNames",
return_value=([expected_file_path], ""),
Expand Down
235 changes: 137 additions & 98 deletions tutorial.ipynb
Original file line number Diff line number Diff line change
@@ -1,101 +1,140 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# arcjetCV Tutorial"
]
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "jWLZa2NcV1fa"
},
"source": [
"# arcjetCV Tutorial"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "su6ZgnRMV1fd",
"outputId": "9a4c5c2f-9d5c-4dde-fe61-bb170302d4eb"
},
"outputs": [],
"source": [
"!pip install git+https://github.com/magnus-haw/arcjetCV.git@develop -q\n",
"!pip install segmentation-models-pytorch -q\n",
"!pip install imageio[pyav] -q # to load m4v\n",
"!wget https://github.com/magnus-haw/arcjetCV/raw/develop/tests/arcjet_test.mp4 -q # example video"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"id": "FEoaneAFV1fe"
},
"outputs": [],
"source": [
"# functions to convert and display videos\n",
"from moviepy.editor import ipython_display as display_video\n",
"import imageio\n",
"def convert_and_crop_video(video_path, output_path, fps=30, max_frames=None):\n",
" frames = imageio.mimread(video_path, memtest=False)\n",
" if max_frames is None:\n",
" n_frames = len(frames)\n",
" else:\n",
" n_frames = min(max_frames, len(frames))\n",
" writer = imageio.get_writer(output_path, fps=fps)\n",
" for i in range(n_frames):\n",
" writer.append_data(frames[i])\n",
" writer.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 779
},
"id": "XjpxFVexV1fe",
"outputId": "1b55f3d0-2953-4ed2-86d9-8fed8ea060ff"
},
"outputs": [],
"source": [
"# crop example video and display it\n",
"convert_and_crop_video(\"arcjet_test.mp4\", \"arcjet_test_crop.mp4\", max_frames=600)\n",
"display_video(\"arcjet_test_crop.mp4\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Ywg0g9myV1fe",
"outputId": "7c54132e-4615-4209-f9f0-a5016eb4b0f6"
},
"outputs": [],
"source": [
"import arcjetCV as arcv\n",
"\n",
"video = arcv.Video(\"arcjet_test.mp4\")\n",
"\n",
"videometa = arcv.VideoMeta(video, \"arcjet_test.meta\")\n",
"videometa[\"FLOW_DIRECTION\"] = \"right\"\n",
"videometa.set_frame_crop(10, 700, 100, 425)\n",
"videometa[\"FIRST_GOOD_FRAME\"] = 100\n",
"videometa[\"LAST_GOOD_FRAME\"] = 400\n",
"\n",
"processor = arcv.ArcjetProcessor(videometa)\n",
"output = processor.process_all(\n",
" video,\n",
" options={\"SEGMENT_METHOD\": \"CNN\"},\n",
" first_frame=videometa[\"FIRST_GOOD_FRAME\"],\n",
" last_frame=videometa[\"LAST_GOOD_FRAME\"],\n",
" frame_stride = 5,\n",
" output_prefix=\"arcjet_test\",\n",
" write_json = True,\n",
" write_video = True\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 831
},
"id": "1S82IKEhV1ff",
"outputId": "edcc1295-a3b0-4f35-ecb0-ccc314f700db"
},
"outputs": [],
"source": [
"# convert annotated video from m4v to mp4 and display it\n",
"convert_and_crop_video(\"video_out_arcjet_test_100_400.m4v\", \"video_out_arcjet_test.mp4\")\n",
"display_video('video_out_arcjet_test.mp4')"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.12.2"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install git+https://github.com/magnus-haw/arcjetCV.git@develop -q\n",
"!pip install segmentation-models-pytorch -q\n",
"!pip install imageio[pyav] -q # to load m4v\n",
"!wget https://github.com/magnus-haw/arcjetCV/raw/main/tests/arcjet_test.mp4 -q # example video"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# functions to convert and display videos\n",
"from moviepy.editor import ipython_display as display_video\n",
"import imageio\n",
"def convert_and_crop_video(video_path, output_path, fps=30, max_frames=None):\n",
" frames = imageio.mimread(video_path, memtest=False)\n",
" if max_frames is None: \n",
" n_frames = len(frames)\n",
" else:\n",
" n_frames = min(max_frames, len(frames))\n",
" writer = imageio.get_writer(output_path, fps=fps)\n",
" for i in range(n_frames):\n",
" writer.append_data(frames[i])\n",
" writer.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# crop example video and display it\n",
"convert_and_crop_video(\"arcjet_test.mp4\", \"arcjet_test.mp4\", max_frames=300)\n",
"display_video(\"arcjet_test.mp4\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import arcjetCV as arcv\n",
"\n",
"video = arcv.Video(\"arcjet_test.mp4\")\n",
"\n",
"videometa = arcv.VideoMeta(video, \"arcjet_test.meta\")\n",
"videometa[\"FLOW_DIRECTION\"] = \"right\"\n",
"videometa.set_frame_crop(30, 670, 120, 680)\n",
"videometa[\"FIRST_GOOD_FRAME\"] = 0\n",
"videometa[\"LAST_GOOD_FRAME\"] = 600\n",
"\n",
"processor = arcv.ArcjetProcessor(videometa)\n",
"output = processor.process_all(\n",
" video, \n",
" options={\"SEGMENT_METHOD\": \"CNN\"}, \n",
" first_frame=videometa[\"FIRST_GOOD_FRAME\"], \n",
" last_frame=videometa[\"LAST_GOOD_FRAME\"], \n",
" frame_stride = 5,\n",
" write_json = True,\n",
" write_video = True\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# convert annotated video from m4v to mp4 and display it\n",
"convert_and_crop_video(\"video_out_arcjet_test.m4v\", \"video_out_arcjet_test.mp4\")\n",
"display_video('video_out_arcjet_test.mp4')"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat": 4,
"nbformat_minor": 0
}
Loading