小编Gab*_*abe的帖子

Matlab面向对象编程:设置和获取多个对象的属性

我有一个这样的课:

classdef Vehicle < handle
    %Vehicle
    %   Vehicle superclass

    properties
        Is_Active  % Does the vehicle exist in the simualtion world?
        Speed      % [Km/Hour]
    end

    methods
        function this = Vehicle(varargin)
            this.Speed = varargin{1}; % The speed of the car
            this.Is_Active = true;
        end
    end
end
Run Code Online (Sandbox Code Playgroud)

我以单元格形式创建了我的Vehicle级对象(不要问我为什么 - 这是全局设置的外行解决方法):

Vehicles{1} = Vehicle(100);
Vehicles{2} = Vehicle(200);
Vehicles{3} = Vehicle(50);
Vehicles{1}.Is_Active = true;
Vehicles{2}.Is_Active = true;
Vehicles{3}.Is_Active = true;
Run Code Online (Sandbox Code Playgroud)

我的问题:1.有没有办法在一个命令中设置所有三个对象的活动状态?2.有没有办法在一个命令中获得所有三个对象的速度?3.有没有办法在一个命令中查询哪些车辆比X快?

谢谢加布里埃尔

oop matlab get class set

7
推荐指数
1
解决办法
1232
查看次数

如何更新页眉和页脚中的字段,而不仅仅是主文档?

在C#中,使用wordDocument.Fields.Update()对主体中的所有内容都很有效.

是否有简洁优雅的方法来更新页眉和页脚中的字段?

c# ms-word header footer office-interop

7
推荐指数
3
解决办法
1989
查看次数

使用 OpenCV 和 Python 多重处理进行持续相机抓取

我不断地用 Python 读取来自 OpenCV 相机的图像,并从主程序中读取最新的图像。这是因为硬件有问题而需要的。

在搞乱了线程并获得非常低的效率(废话!)之后,我想切换到多处理。

这是线程版本:

class WebcamStream:
    # initialization method
    def __init__(self, stream_id=0):
        self.stream_id = stream_id  # default is 0 for main camera

        # opening video capture stream
        self.camera = cv2.VideoCapture(self.stream_id)
        self.camera.set(cv2.CAP_PROP_FRAME_WIDTH, 3840)
        self.camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 2880)

        if self.camera.isOpened() is False:
            print("[Exiting]: Error accessing webcam stream.")
            exit(0)

        # reading a single frame from camera stream for initializing
        _, self.frame = self.camera.read()

        # self.stopped is initialized to False
        self.stopped = True

        # thread instantiation
        self.t = Thread(target=self.update, args=())
        self.t.daemon = True …
Run Code Online (Sandbox Code Playgroud)

python camera multithreading opencv multiprocessing

3
推荐指数
1
解决办法
1599
查看次数

C# - 必须误解一些关于静态的东西

得到了这一小段代码.当我运行它时,我在"Roads_Vertices [i,0] = Convert.ToDouble(Coordinates [0]);"行上得到"对象引用未设置为对象的实例".救命 !

谢谢加布里埃尔

namespace RouteSim
{
static class Program
{
    static double[,] Roads_Vertices;
    static double[,] Roads_Segments;

    static void Main()
    {
        // Declarations and Initializations
        // Read Roads from XML
        Parse_Road_Data();

        // User Interface
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form_MainWindow());
    }

    static void Parse_Road_Data()
    {
        // Reads and parses the Roads XML file
        XmlDocument Road_File = new XmlDocument();
        Road_File.Load(@"D:\My Documents\Visual Studio 2010\Projects\RouteSim\Additional Data\Roads.xml");

        XmlNodeList Road_Vertices_NodeList = Road_File.GetElementsByTagName("Road_Vertex");
        for (int i = 0; i < Road_Vertices_NodeList.Count; i++)
        {
            string[] Coordinates …
Run Code Online (Sandbox Code Playgroud)

c# static

0
推荐指数
1
解决办法
92
查看次数