Skip to content

Commit 1f8863c

Browse files
committed
Added docs for MP4Writer example.
1 parent 8f1d5da commit 1f8863c

File tree

9 files changed

+280
-27
lines changed

9 files changed

+280
-27
lines changed

docs/articles/toc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
href: vision/columnwise_operations.md
2929
- name: VideoAnnotation
3030
href: vision/video_annotation.md
31+
- name: MP4Writer
32+
href: vision/mp4_writer.md
3133
- name: Neuro Tasks
3234
items:
3335
- name: Neuro

docs/articles/vision/columnwise_operations.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,12 @@
66
![Example](~/workflows/examples.starter/Vision/ColumnwiseOperations/ColumnwiseOperations.bonsai)
77
:::
88

9-
Testing text
9+
## Summary
10+
This example demonstrates how to project information of a matrix (in this case an image) into a single row vector using the max function.
11+
12+
## Details
13+
1. Convert the image to gray scale.
14+
2. Project the max values of each column to a single row vector.
15+
16+
## Follow-up
17+
In addition the Max function one can use the Min, Sum, or Mean values. Row-wise operations can also be used by setting the Axis property in the Reduce node to 1.

docs/articles/vision/mp4_writer.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Vision: Video Annotation
2+
3+
:::workflow
4+
![Example](~/workflows/examples.starter/Vision/VideoAnnotation/VideoAnnotation.bonsai)
5+
:::
6+
7+
## Summary
8+
[FFMPEG](https://website-name.com)
9+
10+
11+
## Details
12+
0. Before running workflow download and unzip [ffmpeg](https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl-shared.zip) to a folder in your computer.
13+
14+
1. Write the frames from a camera into ImageWriter, but in the path, instead of a file, you will add a pipe: \\.\pipe\video. Every frame that is written in the pipe is going to be sent the process in 2.
15+
16+
2. Start a process where the filename points to the ffmpeg executable \[ffmpeg\]\bin\ffmpeg.exe and the arguments are the arguments of ffmpeg.
17+
Here we are using:
18+
* -y -f rawvideo -vcodec rawvideo -s 640x480 -r 30 -pix_fmt gray -i \\.\pipe\video -c:v libx264 -b:v 5212K -maxrate 5212K -bufsize 5M "myvideo.mp4"
19+
20+
Options that might need to be adapted for your situation are:
21+
- the size (width and height) of the input images (-s)
22+
- the frame rate (-r)
23+
- the name of the output video (last parameter)
24+
- in case the encoding is rather slow, you might want to append the option '-preset ultrafast' to speed it up.
25+
26+
## Follow-up
27+
For additional information on the encoding options provided by ffmpeg consult the [documentation](https://ffmpeg.org/ffmpeg.html).
28+
29+

workflows/examples.starter/Video Processing/Mp4Converter.bonsai

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
xmlns="https://bonsai-rx.org/2018/workflow">
88
<Workflow>
99
<Nodes>
10+
<Expression xsi:type="Annotation">
11+
<Name>1</Name>
12+
<Text><![CDATA[]]></Text>
13+
</Expression>
1014
<Expression xsi:type="Combinator">
1115
<Combinator xsi:type="cv:CameraCapture">
1216
<cv:Index>0</cv:Index>
@@ -23,6 +27,10 @@
2327
<cv:Overwrite>true</cv:Overwrite>
2428
</Combinator>
2529
</Expression>
30+
<Expression xsi:type="Annotation">
31+
<Name>2</Name>
32+
<Text><![CDATA[]]></Text>
33+
</Expression>
2634
<Expression xsi:type="Combinator">
2735
<Combinator xsi:type="io:StartProcess">
2836
<io:FileName>C:\Users\HugoMarques\Downloads\ffmpeg-master-latest-win64-gpl-shared\bin\ffmpeg.exe</io:FileName>
@@ -37,8 +45,10 @@
3745
<Edges>
3846
<Edge From="0" To="1" Label="Source1" />
3947
<Edge From="1" To="2" Label="Source1" />
40-
<Edge From="3" To="4" Label="Source1" />
48+
<Edge From="2" To="3" Label="Source1" />
4149
<Edge From="4" To="5" Label="Source1" />
50+
<Edge From="5" To="6" Label="Source1" />
51+
<Edge From="6" To="7" Label="Source1" />
4252
</Edges>
4353
</Workflow>
4454
</WorkflowBuilder>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<VisualizerLayout xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
>
5+
<DialogSettings>
6+
<Visible>false</Visible>
7+
<Location>
8+
<X>0</X>
9+
<Y>0</Y>
10+
</Location>
11+
<Size>
12+
<Width>0</Width>
13+
<Height>0</Height>
14+
</Size>
15+
<WindowState>Normal</WindowState>
16+
</DialogSettings>
17+
<DialogSettings>
18+
<Visible>false</Visible>
19+
<Location>
20+
<X>0</X>
21+
<Y>0</Y>
22+
</Location>
23+
<Size>
24+
<Width>0</Width>
25+
<Height>0</Height>
26+
</Size>
27+
<WindowState>Normal</WindowState>
28+
</DialogSettings>
29+
<DialogSettings>
30+
<Visible>false</Visible>
31+
<Location>
32+
<X>0</X>
33+
<Y>0</Y>
34+
</Location>
35+
<Size>
36+
<Width>0</Width>
37+
<Height>0</Height>
38+
</Size>
39+
<WindowState>Normal</WindowState>
40+
</DialogSettings>
41+
<DialogSettings>
42+
<Visible>false</Visible>
43+
<Location>
44+
<X>0</X>
45+
<Y>0</Y>
46+
</Location>
47+
<Size>
48+
<Width>0</Width>
49+
<Height>0</Height>
50+
</Size>
51+
<WindowState>Normal</WindowState>
52+
</DialogSettings>
53+
<DialogSettings>
54+
<Visible>false</Visible>
55+
<Location>
56+
<X>0</X>
57+
<Y>0</Y>
58+
</Location>
59+
<Size>
60+
<Width>0</Width>
61+
<Height>0</Height>
62+
</Size>
63+
<WindowState>Normal</WindowState>
64+
</DialogSettings>
65+
<DialogSettings>
66+
<Visible>false</Visible>
67+
<Location>
68+
<X>0</X>
69+
<Y>0</Y>
70+
</Location>
71+
<Size>
72+
<Width>0</Width>
73+
<Height>0</Height>
74+
</Size>
75+
<WindowState>Normal</WindowState>
76+
</DialogSettings>
77+
<DialogSettings>
78+
<Visible>false</Visible>
79+
<Location>
80+
<X>0</X>
81+
<Y>0</Y>
82+
</Location>
83+
<Size>
84+
<Width>0</Width>
85+
<Height>0</Height>
86+
</Size>
87+
<WindowState>Normal</WindowState>
88+
</DialogSettings>
89+
<DialogSettings>
90+
<Visible>false</Visible>
91+
<Location>
92+
<X>0</X>
93+
<Y>0</Y>
94+
</Location>
95+
<Size>
96+
<Width>0</Width>
97+
<Height>0</Height>
98+
</Size>
99+
<WindowState>Normal</WindowState>
100+
</DialogSettings>
101+
</VisualizerLayout>

workflows/examples.starter/Vision/ColumnwiseOperations/ColumnwiseOperations.bonsai

+11-25
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision"
55
xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp"
6-
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
76
xmlns="https://bonsai-rx.org/2018/workflow">
87
<Workflow>
98
<Nodes>
@@ -13,25 +12,17 @@
1312
<cv:CaptureProperties />
1413
</Combinator>
1514
</Expression>
16-
<Expression xsi:type="Combinator">
17-
<Combinator xsi:type="dsp:Split" />
18-
</Expression>
19-
<Expression xsi:type="MemberSelector">
20-
<Selector>Item2</Selector>
21-
</Expression>
22-
<Expression xsi:type="Combinator">
23-
<Combinator xsi:type="dsp:ConvertToMat" />
24-
</Expression>
25-
<Expression xsi:type="MemberSelector">
26-
<Selector>Item3</Selector>
15+
<Expression xsi:type="Annotation">
16+
<Name>1</Name>
17+
<Text><![CDATA[]]></Text>
2718
</Expression>
2819
<Expression xsi:type="Combinator">
29-
<Combinator xsi:type="dsp:ConvertToMat" />
20+
<Combinator xsi:type="cv:Grayscale" />
3021
</Expression>
31-
<Expression xsi:type="Combinator">
32-
<Combinator xsi:type="rx:Zip" />
22+
<Expression xsi:type="Annotation">
23+
<Name>2</Name>
24+
<Text><![CDATA[]]></Text>
3325
</Expression>
34-
<Expression xsi:type="Subtract" />
3526
<Expression xsi:type="Combinator">
3627
<Combinator xsi:type="dsp:Reduce">
3728
<dsp:Axis>0</dsp:Axis>
@@ -40,15 +31,10 @@
4031
</Expression>
4132
</Nodes>
4233
<Edges>
43-
<Edge From="0" To="1" Label="Source1" />
44-
<Edge From="1" To="2" Label="Source1" />
45-
<Edge From="1" To="4" Label="Source1" />
46-
<Edge From="2" To="3" Label="Source1" />
47-
<Edge From="3" To="6" Label="Source1" />
48-
<Edge From="4" To="5" Label="Source1" />
49-
<Edge From="5" To="6" Label="Source2" />
50-
<Edge From="6" To="7" Label="Source1" />
51-
<Edge From="7" To="8" Label="Source1" />
34+
<Edge From="0" To="2" Label="Source1" />
35+
<Edge From="1" To="2" Label="Source2" />
36+
<Edge From="2" To="4" Label="Source1" />
37+
<Edge From="3" To="4" Label="Source2" />
5238
</Edges>
5339
</Workflow>
5440
</WorkflowBuilder>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<VisualizerLayout xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
>
5+
<DialogSettings>
6+
<Visible>false</Visible>
7+
<Location>
8+
<X>0</X>
9+
<Y>0</Y>
10+
</Location>
11+
<Size>
12+
<Width>0</Width>
13+
<Height>0</Height>
14+
</Size>
15+
<WindowState>Normal</WindowState>
16+
</DialogSettings>
17+
<DialogSettings>
18+
<Visible>false</Visible>
19+
<Location>
20+
<X>0</X>
21+
<Y>0</Y>
22+
</Location>
23+
<Size>
24+
<Width>0</Width>
25+
<Height>0</Height>
26+
</Size>
27+
<WindowState>Normal</WindowState>
28+
</DialogSettings>
29+
<DialogSettings>
30+
<Visible>true</Visible>
31+
<Location>
32+
<X>597</X>
33+
<Y>186</Y>
34+
</Location>
35+
<Size>
36+
<Width>332</Width>
37+
<Height>277</Height>
38+
</Size>
39+
<WindowState>Normal</WindowState>
40+
<VisualizerTypeName>Bonsai.Vision.Design.IplImageVisualizer</VisualizerTypeName>
41+
<VisualizerSettings>
42+
<IplImageVisualizer />
43+
</VisualizerSettings>
44+
</DialogSettings>
45+
<DialogSettings>
46+
<Visible>false</Visible>
47+
<Location>
48+
<X>0</X>
49+
<Y>0</Y>
50+
</Location>
51+
<Size>
52+
<Width>0</Width>
53+
<Height>0</Height>
54+
</Size>
55+
<WindowState>Normal</WindowState>
56+
</DialogSettings>
57+
<DialogSettings>
58+
<Visible>true</Visible>
59+
<Location>
60+
<X>160</X>
61+
<Y>179</Y>
62+
</Location>
63+
<Size>
64+
<Width>332</Width>
65+
<Height>277</Height>
66+
</Size>
67+
<WindowState>Normal</WindowState>
68+
<VisualizerTypeName>Bonsai.Vision.Design.IplImageVisualizer</VisualizerTypeName>
69+
<VisualizerSettings>
70+
<IplImageVisualizer />
71+
</VisualizerSettings>
72+
</DialogSettings>
73+
</VisualizerLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<WorkflowBuilder Version="2.8.1"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:cv="clr-namespace:Bonsai.Vision;assembly=Bonsai.Vision"
5+
xmlns:io="clr-namespace:Bonsai.IO;assembly=Bonsai.System"
6+
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
7+
xmlns="https://bonsai-rx.org/2018/workflow">
8+
<Workflow>
9+
<Nodes>
10+
<Expression xsi:type="Combinator">
11+
<Combinator xsi:type="cv:CameraCapture">
12+
<cv:Index>0</cv:Index>
13+
<cv:CaptureProperties />
14+
</Combinator>
15+
</Expression>
16+
<Expression xsi:type="Combinator">
17+
<Combinator xsi:type="cv:Grayscale" />
18+
</Expression>
19+
<Expression xsi:type="Combinator">
20+
<Combinator xsi:type="cv:ImageWriter">
21+
<cv:Path>\\.\pipe\video</cv:Path>
22+
<cv:Suffix>None</cv:Suffix>
23+
<cv:Overwrite>true</cv:Overwrite>
24+
</Combinator>
25+
</Expression>
26+
<Expression xsi:type="Combinator">
27+
<Combinator xsi:type="io:StartProcess">
28+
<io:FileName>C:\Users\HugoMarques\Downloads\ffmpeg-master-latest-win64-gpl-shared\bin\ffmpeg.exe</io:FileName>
29+
<io:Arguments>-y -f rawvideo -vcodec rawvideo -s 640x480 -r 30 -pix_fmt gray -i \\.\pipe\video -c:v libx264 -b:v 5212K -maxrate 5212K -bufsize 5M "myvideo.mp4"</io:Arguments>
30+
</Combinator>
31+
</Expression>
32+
<Expression xsi:type="Combinator">
33+
<Combinator xsi:type="rx:Last" />
34+
</Expression>
35+
<Expression xsi:type="WorkflowOutput" />
36+
</Nodes>
37+
<Edges>
38+
<Edge From="0" To="1" Label="Source1" />
39+
<Edge From="1" To="2" Label="Source1" />
40+
<Edge From="3" To="4" Label="Source1" />
41+
<Edge From="4" To="5" Label="Source1" />
42+
</Edges>
43+
</Workflow>
44+
</WorkflowBuilder>

0 commit comments

Comments
 (0)