编程介的小学生 2019-09-14 03:01 采纳率: 20.5%
浏览 139

Moving Object Recognition 的程序的编写

Description

There are many scenarios in which we need to know how fast an object is moving. For example, the air-traffic controller in an airport would like to know the speed of a descending plane and give warning if it's too fast or too slow. The speed detection cameras have helped the police to catch the speeding drivers, and so on.

In this problem, you are supposed to write a program to recognize the speed of a moving object.

Assume that an object is moving on a two dimensional plane, with a constant speed and direction. A camera is taking a shot every second. Assume the camera can record the real situation of the plain - you don't need to worry about the view-angle.

The background is black and the only object is white, except some noise introduced by the camera. Anyway, you can assume that the largest continuous white area is always the object. There is always only one largest continuous white area in this problem.

Given several pictures taken by the camera, calculate the speed of the object. Output the speed of the object.

A picture is represented by a matrix which contains "." or "x" only, where"." in the matrix means a black block and "x" means a white block. There are at least two pictures.

Here are some detailed definitions:

The edge of each block is 1 mm (That is, each "." or "x" in the matrix represents one 1mm*1mm block.)

"The speed of the object" is defined by the moving speed of the center of the object as geometric center : . Anyway, all the objects are made of square blocks. The geometric center of a single square block is the center of the block. So the geometric center of the object can be calculated as: . Where (X[i],Y[i]) is the coordinates of the i-th box's center and N is the number of blocks in the object.

A white area is a set of white blocks.

A white area is called "continuous white area" if and only if there is always a path connecting two arbitrary blocks in this area. All the blocks in the path are within this area. And each pair of sequential blocks along this path shares a common edge.

The average speed is calculated as described in the physics textbook: where t is over all the discrete observation time from 0 to T-1. In this problem, we define T as half of the number of observation points. (There are always even number observation points in the test suit.) pos(t) is defined as the observed position of the object's center in time t, that is, calculated from the t-th image.

The positive direction of X axle is from the left to the right; the positive direction of Y axle is from the top to the bottom.

Note that you may get different shape of an object in different pictures.
Input

The input is a file containing several data cases. Each case begins with a line, with only two numbers: m and k. Then follows by several m*k (m columns, k rows) matrices. Each matrix represents one picture taken by the camera. There are at least two pictures. There is always a separator line between each matrix inside a data set. The separator line is a line with m "-"s. The last matrix of a data set is followed by a terminating line - a line with m "="s.

A line with two zeros presents the end of the input file.

The picture size is at most 256*256. There are at most 256 pictures in one test case.
Output

For each test case, output a line with two numbers which represent the speed of the object in X and Y direction respectively. The accuracy is up to 2 digits after decimal point. The speeds of the objects are in mm/s.
Sample Input

10 5
.........x
.....xxx.x
....xxx...
.....xxx..

x.........

.........x
.........x
...xxx....
..xxx.....

x..xxx....

0 0
Sample Output

-2.00 1.00

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀
    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?