如何从监控摄像头录制的视频中读取时间?

发布于 2024-10-08 19:57:45 字数 557 浏览 4 评论 0原文

我有一个问题,我必须从监控摄像头录制的视频中读取录制时间。

时间显示在视频的左上角区域。下面是显示时间的区域屏幕截图的链接。此外,数字颜色(白色/黑色)在视频播放期间不断变化。

替代文本 http://i55.tinypic.com/2j5gca8.png

请引导我接近的方向这个问题。我是一名 Java 程序员,因此更喜欢通过 Java 的方法。

编辑: 感谢unhillbilly的评论。我查看了 Ron Cemer OCR 库,其性能远低于我们的要求。

由于 ocr 性能低于预期,我计划使用所有数字的屏幕抓取来构建字符集,并使用一些图像/像素比较库将帧时间与字符集进行比较,这将显示概率结果比较后。

所以我一直在寻找一个好的图像比较库(我可以使用可以使用命令行运行的非java库)。另外,关于上述方法的任何建议都会非常有帮助。

I have a problem where I have to read the time of recording from the video recorded by a surveillance camera.

The time shows up on the top-left area of the video. Below is a link to screen grab of the area which shows the time. Also, the digit color(white/black) keeps changing during the duration of the video.

alt text
http://i55.tinypic.com/2j5gca8.png

Please guide me in the direction to approach this problem. I am a Java programmer so would prefer an approach through Java.

EDIT:
Thanks unhillbilly for the comment. I had looked at the Ron Cemer OCR library and its performance is much below our requirement.

Since the ocr performance is less than desired, I was planning to build a character set using the screen grabs for all the digits, and using some image/pixel comparison library to compare the frame time with the character-set which will show a probabilistic result after comparison.

So I was looking for a good image comparison library(I would be OK with a non-java library which I can run using the command-line). Also any advice on the above approach would be really helpful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

等待圉鍢 2024-10-15 19:57:46

Java OCR 将非常适合您的情况(这里是 Ron Cemer)。您所需要做的就是删除背景图像,或者使其始终小于 50% 白色,这样当图像转换为单色时,白色字符将变为白色,背景将变为黑色。

在字体上训练 JavaOCR,从图像中提取矩形区域,删除背景,然后就可以开始运行了。

我建议使用一种算法,该算法查看 r、g、b 并将所有内容设置为黑色,其中 r、g、b 的值不完全相同。这将只留下完美的灰色阴影的像素。由于图像是彩色的而数字是单色的,因此会留下数字和一些灰尘。

JavaOCR 希望在白色背景上看到黑色字符,因此完成上述操作后,您还需要反转单色图像(白色 = 黑色,反之亦然)。然后通过 JavaOCR 库运行它,向它传递您希望它识别的所有字符的参考样本,您的问题应该(至少大部分)得到解决。

Java OCR will work perfectly for your situation (Ron Cemer here). All you need to do is remove the background image, or make it always be less than 50% white, so that the white characters will be white and the background will be black when the image is converted to monochrome.

Train JavaOCR on the font, extract that rectangular region from the image, remove the background and you're off and running.

I suggest an algorithm which looks at r,g,b and sets everything to black where r,g,b are not exactly the same values. That will leave only pixels which are perfect shades of gray. Since the image is color and the digits are monochrome, that will leave the digits and some dust.

JavaOCR wants to see black characters on a white background, so once you've done the above, you'll also need to invert the monochrome image (white = black and vice-versa). Then run that through the JavaOCR library, passing it reference samples of all of the characters you expect it to recognize, and your problem should be (at least mostly) solved.

晨曦÷微暖 2024-10-15 19:57:46

尝试使用 Google 的 Tesseract一对 JNI 包装器可用的。确保阅读常见问题解答以仅提取数字。

Try Tesseract from Google, there are a couple of JNI wrappers available. Ensure to read the FAQ to only pull digits.

甜尕妞 2024-10-15 19:57:45

您似乎不需要在这里使用完整的 OCR。
我认为数字始终位于图像中的相同位置。您只期望每个已知位置上有数字 0-9(黑色或白色)。
每个位置与每个数字的简单模板匹配(每种颜色的 10 个数字有 20 个模板)非常快(实时),并且应该为您提供非常准确的结果。

It doesn't seem like you need a full blown OCR here.
I presume that the numbers are always in the same position in the image. You only expect digits 0-9 at each of the know positions (in either black or white).
A simple template matching at each position with each of the digits (you'll have 20 templates for the 10 digits at each color) is very fast (real-time) and should give you very accurate results.

春夜浅 2024-10-15 19:57:45

源文件的格式是什么(vhs、dvd、剧照)?时间戳可能已编码在数据中。

更新更多细节

虽然我完全理解拥有自动化端到端流程的愿望(特别是如果您销售此应用程序而不是创建内部工具),但它会让某人手动输入每个视频的开始时间(即使有数百个视频)比花费数周的编码让它自动工作会更有效。

我会做什么(失败了一个简单、实现速度非常快、超准确的 OCR 解决方案,我认为该解决方案不存在):

创建几个数据库表,例如

video           video_group
-------         -----------
id              id
filename        title
start_time      date_created
group_id        date_modified
date_created    date_deleted
date_modified
date_deleted

video_group 可能包含

id| title
-----------
1 | Unassigned
2 | 711 Mockingbird @ 75
3 | Kroger storage room

video 将通过导入脚本预先填充视频文件名。最初为所有内容分配 group_id 为 1(未分配)

创建一个简单的 Winforms 或 WPF 应用程序(请原谅我的 ASCII 艺术):

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|  Group: [=========]\/ [New group...]                            |
|                                                                 |
|  File:  [=========]\/                                           |
|                                                                 |
|  Preview                                                        |
|  |--------------------------------------| [Next Video]          |
|  | (first frame of selected video here) | [Prev]                |
|  |                                      |                       |
|  |                                      |                       |
|  |                                      |                       |
|  |--------------------------------------|                       |
|  Start Time                                                     |
|  [(enter start time value here as displayed on preview frame)]  |
|                                                                 |
|  [Update]                                                       |
-------------------------------------------------------------------

用户(任何人都可以这样做 - 秘书、看门人,甚至是最近的计算机科学毕业生)。他们所要做的就是从预览帧中读取时间,将其输入到“开始时间”字段中,然后单击“更新”或“下一步”以更新数据库并继续下一个。将组选择从一个视频保留到下一个视频,除非用户更改它。

假设用户需要 30 秒来阅读、输入并单击下一步,他们可以在一小时内完成 100-150 个视频(更实际的估计为 75 个视频)。而且,实习生比开发人员时间便宜很多。

如果您确实有“数百个”视频,那么这样做仍然比使用 OCR 更快。如果 OCR 在大部分情况下都有效,您很可能需要有人手动检查所有内容以查看结果是否正确。这就引出了一个问题,为什么要使用 OCR 呢?

What format is the source in (vhs, dvd, stills)? It's possible that the time stamp is encoded in the data.

Update with more detail

While I completely understand the desire to have an automated end-to-end process (especially if you're selling this app as opposed to creating an in-house tool), it'd be more efficient to have someone manually enter the start time for each video (even if there are hundreds of them ) then to spend weeks of coding getting this to work automatically.

What I'd do (failing a simple, very-fast-to-implement, super-accurate OCR solution which I don't believe exists):

Create a couple of database tables, like

video           video_group
-------         -----------
id              id
filename        title
start_time      date_created
group_id        date_modified
date_created    date_deleted
date_modified
date_deleted

video_group might contain

id| title
-----------
1 | Unassigned
2 | 711 Mockingbird @ 75
3 | Kroger storage room

video would be prepopulated with the video filenames by an import script. Initially assign everything a group_id of 1 (Unassigned)

Create a simple Winforms or WPF app (pardon my ASCII art):

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|  Group: [=========]\/ [New group...]                            |
|                                                                 |
|  File:  [=========]\/                                           |
|                                                                 |
|  Preview                                                        |
|  |--------------------------------------| [Next Video]          |
|  | (first frame of selected video here) | [Prev]                |
|  |                                      |                       |
|  |                                      |                       |
|  |                                      |                       |
|  |--------------------------------------|                       |
|  Start Time                                                     |
|  [(enter start time value here as displayed on preview frame)]  |
|                                                                 |
|  [Update]                                                       |
-------------------------------------------------------------------

A user (anybody could do this - secretary, janitor, even a recent CS graduate). All they have to do is read the time from the preview frame, type it into the Start Time field, and Click "update" or "Next" to update the database and move on to the next one. Keep the Group selection from one video to the next unless the user changes it.

Assuming it takes the user 30 seconds to read, type and click next, They could complete 100-150 videos in an hour (Call it 75 for a more realistic estimate). And, interns are a lot cheaper than developer time.

If you really have "hundreds" of videos, it'll still be faster to do it this way than to screw around with OCR. If the OCR works for the most part, you'll most likely need to have someone manually inspect everything to see if the results are correct. which begs the question, why bother with the OCR?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文