- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
通常我们在 opencv 窗口中显示网络摄像头或视频运动:
CvCapture* capture = cvCreateCameraCapture(0);
cvNamedWindow( "title", CV_WINDOW_AUTOSIZE );
cvMoveWindow("title",x,y);
while(1)
{
frame = cvQueryFrame( capture );
if( !frame )
{
break;
}
cvShowImage( "title", frame );
char c = cvWaitKey(33);
if( c == 27 )
{
break;
}
}
我尝试使用 pictureBox 成功地在 Windows 窗体中显示图像:
pictureBox1->Image = gcnew System::Drawing::Bitmap( image->width,image->height,image->widthStep,System::Drawing::Imaging::PixelFormat::Undefined, ( System::IntPtr ) image-> imageData);
但是当我试图显示从视频中捕获的图像时它不会工作,这是来源:
CvCapture* capture = cvCreateCameraCapture(0);
while(1)
{
frame = cvQueryFrame( capture );
if( !frame )
{
break;
}
pictureBox1->Image = gcnew System::Drawing::Bitmap( frame->width,frame->height,frame->widthStep,System::Drawing::Imaging::PixelFormat::Undefined, ( System::IntPtr ) frame-> imageData);
char c = cvWaitKey(33);
if( c == 27 )
{
break;
}
}
有没有办法使用 windows 窗体而不是 opencv windows 来显示视频或网络摄像头?
还是我的代码有问题?感谢您的帮助..:)
最佳答案
一条建议:使用VideoInput而不是 CvCapture(CvCapture 是 highgui 库的一部分,它不是用于生产用途,而是用于快速测试)。是的,VideoInput 主页看起来很奇怪,但是这个库非常值得。
这里是使用 VideoInput 的快速示例(从 VideoInput.h 文件中提取):
//create a videoInput object
videoInput VI;
//Prints out a list of available devices and returns num of devices found
int numDevices = VI.listDevices();
int device1 = 0; //this could be any deviceID that shows up in listDevices
int device2 = 1; //this could be any deviceID that shows up in listDevices
//if you want to capture at a different frame rate (default is 30)
//specify it here, you are not guaranteed to get this fps though.
//VI.setIdealFramerate(dev, 60);
//setup the first device - there are a number of options:
VI.setupDevice(device1); //setup the first device with the default settings
//VI.setupDevice(device1, VI_COMPOSITE); //or setup device with specific connection type
//VI.setupDevice(device1, 320, 240); //or setup device with specified video size
//VI.setupDevice(device1, 320, 240, VI_COMPOSITE); //or setup device with video size and connection type
//VI.setFormat(device1, VI_NTSC_M); //if your card doesn't remember what format it should be
//call this with the appropriate format listed above
//NOTE: must be called after setupDevice!
//optionally setup a second (or third, fourth ...) device - same options as above
VI.setupDevice(device2);
//As requested width and height can not always be accomodated
//make sure to check the size once the device is setup
int width = VI.getWidth(device1);
int height = VI.getHeight(device1);
int size = VI.getSize(device1);
unsigned char * yourBuffer1 = new unsigned char[size];
unsigned char * yourBuffer2 = new unsigned char[size];
//to get the data from the device first check if the data is new
if(VI.isFrameNew(device1)){
VI.getPixels(device1, yourBuffer1, false, false); //fills pixels as a BGR (for openCV) unsigned char array - no flipping
VI.getPixels(device1, yourBuffer2, true, true); //fills pixels as a RGB (for openGL) unsigned char array - flipping!
}
//same applies to device2 etc
//to get a settings dialog for the device
VI.showSettingsWindow(device1);
//Shut down devices properly
VI.stopDevice(device1);
VI.stopDevice(device2);
关于c++ - OpenCV : How to display webcam capture in windows form application?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2863918/
我一直在阅读 Captures这一段引起了我的兴趣: Inside a Signature, a Capture may be created by prefixing a sigilless par
我在 Java 中使用这个正则表达式: ^(Mon(?:.?|day)?)(?:[\.,])?$ (可以测试 here ) 我想捕获日期,后跟可选的 . 或 ,。如果是星期一,我想捕获 Monday
我正在 try catch 功能键 F1 到 F12 和 4 个箭头键以及主页、插入、删除、结束、向上翻页和向下翻页键。如何???? private void Form1_KeyPress(objec
没有capture="camera" input type="file" 的属性标签 in official w3.org documentation . 讽刺的是,我发现了这么多地方 capture
摘自Huon Wilson的Finding Closure in Rust: Capturing entirely by value is also strictly more general tha
所以我想这样做: public interface IFieldObject { public Comparable get(); } public interface IFieldCondi
我希望使用正则表达式将单词分成组(vowels, not_vowels, more_vowels),使用标记来确保每个单词以元音开头和结尾。 import re MARKER = "~" VOWELS
我在浏览 StackOverflow 时发现了 Szimek/Signature_Pad 以使用 Javascript 捕获电子/数字签名。 我研究过,但我仍然对如何将 DATA URI 捕获到变量中
我正在尝试关注 this example使用带有 remove_if 的 lambda。这是我的尝试: int flagId = _ChildToRemove->getId(); auto new_e
我无法捕获 在屏幕捕获区域内。 我想要一个定义的部分,其中包含要捕获的图像和内容。我们怎样才能做到这一点?帮助! 访问:https://stackblitz.com/edit/ngx-capture-
从 Perl 脚本调用外部程序时,Capture::Tiny 是否避免了使用 system() 时需要的磁盘 io?使用任何一种时,我都能获得基本相同的性能。一位同事正在使用我的代码并告诉我它正在敲打
作为数值方法研究的一部分,我正在编写一个函数来解决流值问题。这是该程序的“核心”,但它出现了一些奇怪的错误,这很奇怪,因为我在其他程序中使用了相同的代码段而没有出现任何错误。 void solve_
vector vec; //a auto foo = [&vec](){ //do something }; //b auto foo = [&v = vec](){ //do som
我正在使用 PyDev 对我的 Python 应用程序进行开发和单元测试。至于单元测试,除了没有内容被记录到日志框架之外,一切都很好。 PyDev 的“捕获的输出”没有捕获记录器。 我已经将记录的所有
你能帮我解决这个编译器错误吗? template static void ComputeGenericDropCount(function func) { T::ForEach([](T *w
第一次做泛型,我有点困惑。 我有以下内容: public interface GenericDao { /** * Retrieve an object that was previ
我正在尝试提取此代码中 dir_entry.path() 的值并想将其复制到 compFileName 中。问题是我一直收到错误“compFileName cannot be implicitly c
我正在使用在网上找到的 WebCam_Capture 代码通过 C# 访问网络摄像头。在一台只有一个视频源的计算机上,它就像一个魅力! (程序在启动时启动,找到网络摄像头并正常工作)。 虽然在一台有很
下面的代码 void CMainWindow::someMethod(const CLocationsCollection& parentItem) { auto f = [this, par
所以我打开了一个 youtube 页面,我可以在那里观看视频。 但是这个视频被用户下架了。我打开的页面仍然有视频,如果你再次访问(刷新)新页面没有。 由于我在浏览器选项卡 (chrome) 中加载了视
我是一名优秀的程序员,十分优秀!