C#将类实例存储在数组中以用于其他形式(C# Storing class instances in an array to use in other forms)
所以我有我自己的类,我想通过按钮点击类存储类的一个实例,然后在同一个项目下以不同的形式使用这个数组,但尽管声明为公共静态我仍然无法访问它在我的其他形式。 我甚至试图把它放入课堂本身来看看是否可行。 我听说你可以使用列表数组,但我不知道我将如何做,并再次如何访问它在我的整个项目。
对不起,如果我错过了明显的东西,或者我对C#相当陌生。
So i have my own class and i want to store an instance of the class by button click into a class array and then use this array in a different form under the same project however despite declaring it as public static i still can't access it on my other form. I have even tried putting it into the class itself just to see if that would work. I have heard you can use a list array but i am not sure how i would do that and again how to access it over my whole project.
Sorry if i missed something obvious or anything I'm fairly new to C#.
原文:https://stackoverflow.com/questions/40631540
最满意答案
应该只有一个线程操作GUI(对于任何GUI框架都是如此)。 您应该组织代码,以便
cvShowImage
主“GUI线程”调用cvShowImage
。看来在
query_thread
中完成的工作可以在主线程中轻松完成。There should only be one thread manipulating the GUI (this is true for just about any GUI framework). You should organize your code so that
cvShowImage
is only invoked from the main "GUI thread".It seems that the work that's being done in
query_thread
could just as easily be done inside the main thread.
相关问答
更多-
澄清一下,你使用C还是C ++? 如果您使用C ++,请使用OpenCV的C ++接口。 下面的例子适用于我: #include
int main() { //initialize and allocate memory to load the video stream from camera cv::VideoCapture camera0(0); cv::VideoCapture camera1(1); if( !camer ... -
我想出来了。 当我在VLC中打开捕获时,我注意到它将文件名与v4l2:// 。 当我在我的应用程序中做同样的事情时,它工作了! 因此,要在上面引用, "/dev/my_custom_name"应该变为"v4l2:///dev/my_custom_name" 。 I figured this out. When I opened the capture in VLC, I noticed that it preixed the filename with v4l2://. When I did the sam ...
-
应该只有一个线程操作GUI(对于任何GUI框架都是如此)。 您应该组织代码,以便cvShowImage主“GUI线程”调用cvShowImage 。 看来在query_thread中完成的工作可以在主线程中轻松完成。 There should only be one thread manipulating the GUI (this is true for just about any GUI framework). You should organize your code so that cvShowI ...
-
每个网络摄像头都连接到不同的USB端口? 如果是这样,它很好。 即使它只有1个端口,4个连接的网络摄像头。 我不认为4 320x240也会有任何问题。 USB 2.0 = 320Mbps 。 流式传输320x240视频不会超过1mbps。 最糟糕的情况是,将320x240放在2mbps + 1mb的其他数据上。 这将是你的usb端口和设备之间的12mbps带宽。 因此,从上面看,1个USB端口可以处理由分路器连接的4个网络摄像头,速度与1 640x480网络摄像头一样快。 处理这些图像取决于您的计算机速度以 ...
-
提升线程(BOOST THREADING)[2023-05-02]
您或许可以使用未来 。 您可以将未来视为线程之间的共享值。 一个线程将写入未来的值,另一个线程将读取它。 如果尚未编写未来,则读取线程将阻塞,直到它具有。 期货已经成为boost.threads的一部分。 You may be able to use a future. You can think of a future as a shared value between threads. One thread will write the value of the future and another t ... -
我不使用boost很多,但是你不需要做一些事情来保持main()在你的线程工作时退出吗? 就像也许...... int main() { boost::thread trackerThread( boost::bind(openCamera) ); trackerThread.join(); } I don't use boost a lot, but don't you need to do something to keep main() from exiting while your ...
-
你不能。 一次只能有一个应用程序可以访问任何设备 - 即使使用常见的I / O设备(如硬盘)也是如此。 如果多个应用程序可以同时访问设备,则会混淆其遵循的说明。 但是,您可以使用SplitCam。 它将连接到网络摄像头(没有其他应用程序可以)。 但它将创建其他应用程序可以连接的虚拟设备。 You can't. Only one application can access any device at a time - even with common I/O devices like hard disks. ...
-
OpenGL +多个摄像头(OpenGL + multiple cameras)[2021-11-13]
这个可以吗? 是的,就是这样。 是否有另一种方法来分割屏幕而不重复对象? 你不是在复制对象。 你不能,因为在OpenGL中没有“对象”这样的东西。 OpenGL只是一种在帧缓冲区上绘制的复杂铅笔。 没有场景,没有物体,只有点,线和三角形绘制到帧缓冲区。 你所要做的就是从不同的角度画出几张相同的东西,就像你想用纸笔做的那样。 Is this okay? Yes, that's how it goes. Is there another way to split the screen without dupli ... -
我在OSX上使用Python时遇到了这个问题。 我的解决方案是使用--with-ffmpeg标志重建opencv。 I just had this exact problem using Python on OSX. The solution for me was to rebuild opencv using the --with-ffmpeg flag.
-
我从你的标签看到你正在使用Qt。 因此,我建议使用QThreads,如果你还没有,因为他们使很多事情变得更容易。 使用QThreads时,您创建一个为每个辅助线程继承QObject的类。 至于线程的数量,我认为你会想要至少3(主要或用户界面,视频和串行端口)。 你可以做更多,但我不会,除非你有特定的需求(例如,我经常使用2个助手线程的视频,一个捕获和一个处理)。 我建议在信号和插槽的线程之间进行通信,而不是直接调用函数。 有许多方法可以使用不同的ConnectionTypes在Qt中的线程之间进行连接 。 ...