Skip to content

Commit da73c47

Browse files
committed
play_camera and cv
1 parent d51bcf4 commit da73c47

19 files changed

+358
-305
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
*.exe
99
/1-AsyncImageRecordingSample/obj/Debug/
1010
/1-AsyncImageRecordingSample/bin/Debug/
11+
/doc/temp/

1-AsyncImageRecordingSample/Form1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ private void startCaptureButton_Click(object sender, EventArgs e)
278278
error = Jai_FactoryWrapper.J_Image_FromRawToImage(ref ii, ref localImageInfo, 4096, 4096, 4096);
279279

280280
// Save the image to disks
281-
error = Jai_FactoryWrapper.J_Image_SaveFile(ref localImageInfo, "E:\\ArmsWork\\WX_jump\\wechat_jump\\" + "phone.png");
281+
error = Jai_FactoryWrapper.J_Image_SaveFile(ref localImageInfo, "E:\\ArmsWork\\WX_jump\\wechat_jump\\doc\\temp\\" + "phone.png");
282282

283283
//Free the conversion buffer
284284
error = Jai_FactoryWrapper.J_Image_Free(ref localImageInfo);

1-AsyncImageRecordingSample/bin/Release/log4net.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@
780780
<remarks>
781781
<para>
782782
In the rather exceptional case, where the appender
783-
implementation admits a layout but can also work without it,
783+
implementation admits a layout but can also press_screen without it,
784784
then the appender should return <c>true</c>.
785785
</para>
786786
<para>
@@ -1808,13 +1808,13 @@
18081808
<item><term>Bright</term><description>foreground is brighter</description></item>
18091809
<item><term>Dim</term><description>foreground is dimmer</description></item>
18101810
<item><term>Underscore</term><description>message is underlined</description></item>
1811-
<item><term>Blink</term><description>foreground is blinking (does not work on all terminals)</description></item>
1811+
<item><term>Blink</term><description>foreground is blinking (does not press_screen on all terminals)</description></item>
18121812
<item><term>Reverse</term><description>foreground and background are reversed</description></item>
18131813
<item><term>Hidden</term><description>output is hidden</description></item>
18141814
<item><term>Strikethrough</term><description>message has a line through it</description></item>
18151815
</list>
18161816
While any of these attributes may be combined together not all combinations
1817-
work well together, for example setting both <i>Bright</i> and <i>Dim</i> attributes makes
1817+
press_screen well together, for example setting both <i>Bright</i> and <i>Dim</i> attributes makes
18181818
no sense.
18191819
</para>
18201820
</remarks>
@@ -4777,7 +4777,7 @@
47774777
<remarks>
47784778
<note>
47794779
This appender uses the POSIX libc library functions <c>openlog</c>, <c>syslog</c>, and <c>closelog</c>.
4780-
If these functions are not available on the local system then this appender will not work!
4780+
If these functions are not available on the local system then this appender will not press_screen!
47814781
</note>
47824782
<para>
47834783
The functions <c>openlog</c>, <c>syslog</c>, and <c>closelog</c> are specified in SUSv2 and
@@ -6421,8 +6421,8 @@
64216421
</summary>
64226422
<remarks>
64236423
<para>
6424-
This method waits while there are queued work items. The events are
6425-
sent asynchronously using <see cref="T:System.Threading.ThreadPool"/> work items. These items
6424+
This method waits while there are queued press_screen items. The events are
6425+
sent asynchronously using <see cref="T:System.Threading.ThreadPool"/> press_screen items. These items
64266426
will be sent once a thread pool thread is available to send them, therefore
64276427
it is possible to close the appender before all the queued events have been
64286428
sent.</para>
@@ -6438,12 +6438,12 @@
64386438
</member>
64396439
<member name="M:log4net.Appender.RemotingAppender.BeginAsyncSend">
64406440
<summary>
6441-
A work item is being queued into the thread pool
6441+
A press_screen item is being queued into the thread pool
64426442
</summary>
64436443
</member>
64446444
<member name="M:log4net.Appender.RemotingAppender.EndAsyncSend">
64456445
<summary>
6446-
A work item from the thread pool has completed
6446+
A press_screen item from the thread pool has completed
64476447
</summary>
64486448
</member>
64496449
<member name="M:log4net.Appender.RemotingAppender.SendBufferCallback(System.Object)">
@@ -6474,10 +6474,10 @@
64746474
</member>
64756475
<member name="F:log4net.Appender.RemotingAppender.m_workQueueEmptyEvent">
64766476
<summary>
6477-
Event used to signal when there are no queued work items
6477+
Event used to signal when there are no queued press_screen items
64786478
</summary>
64796479
<remarks>
6480-
This event is set when there are no queued work items. In this
6480+
This event is set when there are no queued press_screen items. In this
64816481
state it is safe to close the appender.
64826482
</remarks>
64836483
</member>
@@ -6737,7 +6737,7 @@
67376737
</member>
67386738
<member name="M:log4net.Appender.RollingFileAppender.InitializeFromOneFile(System.String,System.String)">
67396739
<summary>
6740-
Does the work of bumping the 'current' file counter higher
6740+
Does the press_screen of bumping the 'current' file counter higher
67416741
to the highest count when an incremental file name is seen.
67426742
The highest count is either the first file (when count direction
67436743
is greater than 0) or the last file (when count direction less than 0).
@@ -22498,7 +22498,7 @@
2249822498
</para>
2249922499
<note>
2250022500
The Compact Framework 1.0 the <see cref="M:System.String.Intern(System.String)"/>
22501-
method does not work. On the Compact Framework
22501+
method does not press_screen. On the Compact Framework
2250222502
the string keys are not interned nor are they
2250322503
compared by reference.
2250422504
</note>
@@ -26695,7 +26695,7 @@
2669526695
</member>
2669626696
<member name="T:log4net.Util.PatternParser">
2669726697
<summary>
26698-
Most of the work of the <see cref="T:log4net.Layout.PatternLayout"/> class
26698+
Most of the press_screen of the <see cref="T:log4net.Layout.PatternLayout"/> class
2669926699
is delegated to the PatternParser class.
2670026700
</summary>
2670126701
<remarks>

README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
## 运行识别与操作程序
1111
`python AllForOne.py`运行程序,界面如下
12-
![](doc/gui.png)
12+
![](doc/pic/gui.png)
1313

1414
在框中填入手机的分辨率,然后点击`play`开始`stop`停止。
1515

@@ -21,12 +21,7 @@
2121
## 载入待识别图片与模版
2222
载入棋子,结束以及白点的模版:
2323

24-
```python
25-
# Load Template For player,end,and withe circle.
26-
temp1 = cv2.imread('temp_player.jpg', 0)
27-
temp_end = cv2.imread('temp_end.jpg', 0)
28-
temp_white_circle = cv2.imread('temp_white_circle.jpg', 0)
29-
```
24+
3025

3126
载入并旋转图片:
3227

@@ -56,7 +51,7 @@ img_rgb = cv2.flip(img_rgb, 0);
5651
7. 通过透视变换转成一个750x1334分辨率的屏幕`cv2.warpPerspective(canny_img, M, (1080, 1920))`
5752

5853
原图
59-
![](phone.png)
54+
![](doc/temp/phone.png)
6055

6156
处理后
6257
![](pre.png)
@@ -86,7 +81,7 @@ if max_val2 > 0.91:
8681
如果没匹配到白点的话,则我们需要自己找到目标点,先删除棋子的边缘值,由于预处理过程并不能保证很理想,所以在这里我们自己想了个解决方案,我们从400(上面的数字部分跳过)开始,从上往下遍历,设置一个maxl(记录所遇到的行的最左最右点的最大间隔),如果连续三行都小于maxl,则认为maxl即我们需要找的物块行,再取平均,就得到了中心点位置。详细代码见`play.py``get_center()`实现。
8782

8883
结果
89-
![](last.png)
84+
9085

9186
## 计算目标时间
9287
直接计算欧式距离,再乘以一与手机相关的参数,即可得到时间

canny_img00.png

-59.3 KB
Binary file not shown.

directory.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
here is some paths of the project
3+
"""
4+
pattern_dir = 'doc/pattern/'
5+
temp_dir = 'doc/temp/'

camera.md renamed to doc/camera.md

Lines changed: 114 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,115 @@
1-
# 相机文档
2-
---
3-
4-
### 相机程序逻辑
5-
6-
7-
- 运行相机程序,会出现相机程序的gui,如图:
8-
9-
![](doc/camera_gui.JPG)
10-
11-
- **Recording count**变量的框设置为数值1,因为我们每次只需拍一张图片,用作python程序的输入来处理图片。
12-
13-
- 点击**Start**开始拍照,拍照的流程如下:
14-
- 判断是否启动相机实例,只有存在实例的情况下进入`while`循环,进行照片的获取、记录和保存。
15-
- 在`while`循环中,首先判断相机是否已经在记录当中且已经记录了至少一张图片,如果为真的话则停止记录,清除缓存,再打开相机记录;为假的话则直接打开相机记录。
16-
- 接着延迟200ms,处理所有的当前在消息队列中的Windows消息。
17-
- 再次判断相机是否已经在记录或者至少记录了一张图片,为真时进入以下流程:从缓冲区获取已记录的照片的列表,将照片保留,清除缓存,释放已分配内存。
18-
- 接着再一次停止记录,关掉图片获取,打开图片获取(此时已执行完`while`循环内的内容)。
19-
20-
- 由于每次存的图片命名是相同的,每次新图片会强制覆盖旧图片,而机械臂收回到相机范围外停留时间远大于每次拍照时间,所以python处理的最新图片不会有机械臂的影响
21-
22-
23-
24-
25-
26-
27-
```cs
28-
private void startCaptureButton_Click(object sender, EventArgs e);
29-
```
30-
这个函数是相机gui里**Start**按钮对应的事件函数,也是我们需要点击操作来启动相机程序。当启动相机程序后,就不需要对其进行任何操作了。
31-
32-
`StartAsyncImageRecording` 开始图片记录的函数
33-
34-
`StartImageAcquisition` 开始图片获取的函数(调用后并未写入内存)
35-
36-
`StopAcquisition` 停止获取图片的函数
37-
38-
### 核心代码
39-
40-
```cs
41-
private void startCaptureButton_Click(object sender, EventArgs e)
42-
{
43-
while (myCamera != null)
44-
{
45-
if (myCamera.IsAsyncImageRecordingRunning || (myCamera.TotalAsyncImagesRecordedCount > 0))
46-
{
47-
myCamera.StopAsyncImageRecording();
48-
myCamera.FreeAsyncRecordedImages();
49-
myCamera.StartAsyncImageRecording(Convert.ToInt32(captureCountNumericUpDown.Value), (CCamera.AsyncImageRecordingMode)recordingModeComboBox.SelectedIndex, Convert.ToInt32(skipCountNumericUpDown.Value));
50-
}
51-
else
52-
{
53-
myCamera.StartAsyncImageRecording(Convert.ToInt32(captureCountNumericUpDown.Value), (CCamera.AsyncImageRecordingMode)recordingModeComboBox.SelectedIndex, Convert.ToInt32(skipCountNumericUpDown.Value));
54-
}
55-
56-
Delay(200);
57-
58-
Application.DoEvents();
59-
if (!myCamera.IsAsyncImageRecordingRunning && (myCamera.TotalAsyncImagesRecordedCount > 0))
60-
{
61-
// Prompt the user if he wants to continue or not with the image save
62-
// if (MessageBox.Show(this, "Image save might take long time!\nAre you sure you want to continue?", "Image Save", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
63-
// {
64-
// Disable the Image Recording buttons as long as we are saving the images
65-
//asynchImageRecordingGroupBox.Enabled = false;
66-
67-
// Get the recorded images as a list
68-
List<Jai_FactoryWrapper.ImageInfo> imageList = myCamera.GetAsyncRecordedImages();
69-
70-
// Any images recorded?
71-
72-
if (imageList != null && (imageList.Count > 0))
73-
{
74-
// Run through the list of recorded images
75-
int index = myCamera.TotalAsyncImagesRecordedCount - 1;
76-
Jai_FactoryWrapper.EFactoryError error = Jai_FactoryWrapper.EFactoryError.Success;
77-
78-
// Get the recorded image at this index
79-
Jai_FactoryWrapper.ImageInfo ii = imageList[index];
80-
81-
// Are we saving the images in "raw" format or in Tiff?
82-
83-
// Create local image that will contain the converted image
84-
Jai_FactoryWrapper.ImageInfo localImageInfo = new Jai_FactoryWrapper.ImageInfo();
85-
86-
// Allocate buffer that will contain the converted image
87-
// In this sample we re-allocate the buffer over-and-over because we assume that the recorded images could be
88-
// of different size (If we have been using the Sequence functionality in the cameras)
89-
error = Jai_FactoryWrapper.J_Image_Malloc(ref ii, ref localImageInfo);
90-
91-
// Convert the raw image to image format
92-
error = Jai_FactoryWrapper.J_Image_FromRawToImage(ref ii, ref localImageInfo, 4096, 4096, 4096);
93-
94-
// Save the image to disks
95-
error = Jai_FactoryWrapper.J_Image_SaveFile(ref localImageInfo, "..\\" + "phone.png");
96-
97-
//error = Jai_FactoryWrapper.J_Image_SaveFile(ref localImageInfo, "C:\\Users\\aida\\Desktop\\wechat_jump\\" + "phone.png");
98-
99-
//Free the conversion buffer
100-
error = Jai_FactoryWrapper.J_Image_Free(ref localImageInfo);
101-
102-
Application.DoEvents();
103-
104-
}
105-
myCamera.StopAsyncImageRecording();
106-
myCamera.StopImageAcquisition();
107-
myCamera.StartImageAcquisition(true, 5);
108-
109-
// Re-enable the Image Recording buttons
110-
//asynchImageRecordingGroupBox.Enabled = true;
111-
//}
112-
}
113-
}
114-
}
1+
# 相机文档
2+
---
3+
4+
### 相机程序逻辑
5+
6+
7+
- 运行相机程序,会出现相机程序的gui,如图:
8+
9+
![](pic/camera_gui.JPG)
10+
11+
- **Recording count**变量的框设置为数值1,因为我们每次只需拍一张图片,用作python程序的输入来处理图片。
12+
13+
- 点击**Start**开始拍照,拍照的流程如下:
14+
- 判断是否启动相机实例,只有存在实例的情况下进入`while`循环,进行照片的获取、记录和保存。
15+
- 在`while`循环中,首先判断相机是否已经在记录当中且已经记录了至少一张图片,如果为真的话则停止记录,清除缓存,再打开相机记录;为假的话则直接打开相机记录。
16+
- 接着延迟200ms,处理所有的当前在消息队列中的Windows消息。
17+
- 再次判断相机是否已经在记录或者至少记录了一张图片,为真时进入以下流程:从缓冲区获取已记录的照片的列表,将照片保留,清除缓存,释放已分配内存。
18+
- 接着再一次停止记录,关掉图片获取,打开图片获取(此时已执行完`while`循环内的内容)。
19+
20+
- 由于每次存的图片命名是相同的,每次新图片会强制覆盖旧图片,而机械臂收回到相机范围外停留时间远大于每次拍照时间,所以python处理的最新图片不会有机械臂的影响
21+
22+
23+
24+
25+
26+
27+
```cs
28+
private void startCaptureButton_Click(object sender, EventArgs e);
29+
```
30+
这个函数是相机gui里**Start**按钮对应的事件函数,也是我们需要点击操作来启动相机程序。当启动相机程序后,就不需要对其进行任何操作了。
31+
32+
`StartAsyncImageRecording` 开始图片记录的函数
33+
34+
`StartImageAcquisition` 开始图片获取的函数(调用后并未写入内存)
35+
36+
`StopAcquisition` 停止获取图片的函数
37+
38+
### 核心代码
39+
40+
```cs
41+
private void startCaptureButton_Click(object sender, EventArgs e)
42+
{
43+
while (myCamera != null)
44+
{
45+
if (myCamera.IsAsyncImageRecordingRunning || (myCamera.TotalAsyncImagesRecordedCount > 0))
46+
{
47+
myCamera.StopAsyncImageRecording();
48+
myCamera.FreeAsyncRecordedImages();
49+
myCamera.StartAsyncImageRecording(Convert.ToInt32(captureCountNumericUpDown.Value), (CCamera.AsyncImageRecordingMode)recordingModeComboBox.SelectedIndex, Convert.ToInt32(skipCountNumericUpDown.Value));
50+
}
51+
else
52+
{
53+
myCamera.StartAsyncImageRecording(Convert.ToInt32(captureCountNumericUpDown.Value), (CCamera.AsyncImageRecordingMode)recordingModeComboBox.SelectedIndex, Convert.ToInt32(skipCountNumericUpDown.Value));
54+
}
55+
56+
Delay(200);
57+
58+
Application.DoEvents();
59+
if (!myCamera.IsAsyncImageRecordingRunning && (myCamera.TotalAsyncImagesRecordedCount > 0))
60+
{
61+
// Prompt the user if he wants to continue or not with the image save
62+
// if (MessageBox.Show(this, "Image save might take long time!\nAre you sure you want to continue?", "Image Save", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
63+
// {
64+
// Disable the Image Recording buttons as long as we are saving the images
65+
//asynchImageRecordingGroupBox.Enabled = false;
66+
67+
// Get the recorded images as a list
68+
List<Jai_FactoryWrapper.ImageInfo> imageList = myCamera.GetAsyncRecordedImages();
69+
70+
// Any images recorded?
71+
72+
if (imageList != null && (imageList.Count > 0))
73+
{
74+
// Run through the list of recorded images
75+
int index = myCamera.TotalAsyncImagesRecordedCount - 1;
76+
Jai_FactoryWrapper.EFactoryError error = Jai_FactoryWrapper.EFactoryError.Success;
77+
78+
// Get the recorded image at this index
79+
Jai_FactoryWrapper.ImageInfo ii = imageList[index];
80+
81+
// Are we saving the images in "raw" format or in Tiff?
82+
83+
// Create local image that will contain the converted image
84+
Jai_FactoryWrapper.ImageInfo localImageInfo = new Jai_FactoryWrapper.ImageInfo();
85+
86+
// Allocate buffer that will contain the converted image
87+
// In this sample we re-allocate the buffer over-and-over because we assume that the recorded images could be
88+
// of different size (If we have been using the Sequence functionality in the cameras)
89+
error = Jai_FactoryWrapper.J_Image_Malloc(ref ii, ref localImageInfo);
90+
91+
// Convert the raw image to image format
92+
error = Jai_FactoryWrapper.J_Image_FromRawToImage(ref ii, ref localImageInfo, 4096, 4096, 4096);
93+
94+
// Save the image to disks
95+
error = Jai_FactoryWrapper.J_Image_SaveFile(ref localImageInfo, "..\\" + "phone.png");
96+
97+
//error = Jai_FactoryWrapper.J_Image_SaveFile(ref localImageInfo, "C:\\Users\\aida\\Desktop\\wechat_jump\\" + "phone.png");
98+
99+
//Free the conversion buffer
100+
error = Jai_FactoryWrapper.J_Image_Free(ref localImageInfo);
101+
102+
Application.DoEvents();
103+
104+
}
105+
myCamera.StopAsyncImageRecording();
106+
myCamera.StopImageAcquisition();
107+
myCamera.StartImageAcquisition(true, 5);
108+
109+
// Re-enable the Image Recording buttons
110+
//asynchImageRecordingGroupBox.Enabled = true;
111+
//}
112+
}
113+
}
114+
}
115115
```
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)