简体   繁体   English

如何获得作为摄像机输入的视频播放?

[英]How to get playing video as a camera input?

i want to detect specific object from live ongoing video.so i implement frame extraction part(opencv, c++) as one part and other detection function(emgucv, c#) for other part. 我想从正在播放的实时视频中检测特定对象,因此我将帧提取部分(opencv,c ++)作为一部分实现,并将其他检测功能(emgucv,c#)作为另一部分实现。 for integrating those part i added exe file of c++ project to c# project and that is working well. 为了集成这些部分,我在C#项目中添加了c ++项目的exe文件,并且运行良好。 but now i want to test this project in offline. 但是现在我想离线测试这个项目。 That mean i want to test this project by using video that saved in hard disk. 这意味着我想通过使用保存在硬盘中的视频来测试该项目。 before integration,c++ project could able to execute on both online and offline situations. 在集成之前,c ++项目可以在联机和脱机情况下执行。 but after integration that could execute only in online condition. 但整合后只能在在线条件下执行。 please help me to solve this. 请帮助我解决这个问题。

You can always try webcamera emulators like Magic Camera, Fake Webcam or whatever (just google it, there are a bunch of software all over the internet) – they would play a video file as if it was coming from your webcamera. 您可以随时尝试使用Magic Camera,Fake Webcam之类的网络摄像头模拟器(或只是在Google上搜索,互联网上有一堆软件),它们会像播放视频一样来自您的网络摄像头。

However, you might also want to think of re-organizing your software design so that it could accept both streams and file inputs – it should be very straightforward once you separate the processing logic from the capture logic. 但是,您可能还想考虑重新组织软件设计,以便它既可以接受流又可以接受文件输入-一旦将处理逻辑与捕获逻辑分开,它应该非常简单。

A live video camera is basically an asynchronous source of image frames. 实时摄像机基本上是图像帧的异步源。 Presumably you pass a callback function to the camera API, and that callback is triggered upon a new frame's availability? 大概您将回调函数传递给了相机API,并且该回调是在新帧可用时触发的吗? You can mimick this functionality in a fairly straightfoward fashion. 您可以以一种直截了当的方式模仿此功能。

Write a function which opens your video file, and then runs in a loop... each iteration of the loop, it grabs a frame from the file, packages it up appropriately and then calls your callback function. 编写一个打开视频文件的函数,然后循环运行...循环的每次迭代,它都会从文件中获取一个帧,将其适当打包,然后调用您的回调函数。 It can then sleep for a few milliseconds, and then repeat the loop. 然后它可以休眠几毫秒,然后重复该循环。 Run this function in its own thread. 在其自己的线程中运行此函数。 From the point of view of the callback, it is no different from a live camera. 从回调的角度来看,它与实时摄像机没有什么不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM