Beispiel #1
0
    def read(self):
        """Reads all devices from the database and creates filterchains
        
        TODO: we can, of course, just modify the added / removed cameras
        """
        self.reset()

        # take some stuff from the general config
        config = next(self.datamodel.config_collection.get())
        if config["overwrite_timestamps"]:
            self.time_correction = core.TimeCorrectionType_dummy
        else:
            self.time_correction = core.TimeCorrectionType_smart

        for dic in self.datamodel.camera_collection.get(
        ):  # TODO: search directly for RTSPCameraRow
            if (self.verbose): print(self.pre, "read : dic", dic)
            affinity = -1
            if self.cpu_scheme is not None:
                affinity = self.cpu_scheme.getAV()
            classname = dic.pop("classname")

            if classname == RTSPCameraRow.__name__:
                device = RTSPCameraDevice(
                    **dic)  # a neat object with useful methods
                self.context_type = ContextType.live
            elif classname == USBCameraRow.__name__:
                device = USBCameraDevice(
                    **dic)  # a neat object with useful methods
                self.context_type = ContextType.usb
            else:
                print(self.pre, "no context for classname", classname)
                continue

            # chain = ManagedFilterchain( # decoding and branching the stream happens here
            # chain = ManagedFilterchain2( # decoding and branching the stream happens here
            # chain = LiveManagedFilterchain( # decoding and branching the stream happens here
            chain = MultiForkFilterchain(  # decoding and branching the stream happens here
                context_type=self.context_type,
                livethread=self.livethread,
                usbdevicethread=self.usbthread,
                openglthreads=self.gpu_handler.openglthreads,
                address=device.getMainAddress(),
                slot=device.getLiveMainSlot(),
                _id=device._id,
                affinity=affinity,
                msreconnect=10000,
                # verbose     = True,
                verbose=False,
                time_correction=self.
                time_correction,  # overwrite timestamps or not?
                shmem_image_dimensions=constant.shmem_image_dimensions,
                shmem_n_buffer=constant.shmem_n_buffer,
                shmem_image_interval=constant.shmem_image_interval)
            self.chains.append(
                chain
            )  # important .. otherwise chain will go out of context and get garbage collected
Beispiel #2
0
    def getDevice(self, **kwargs):
        """Like get, but returns a Device instance (RTSPCameraDevice, etc.)

        You can pass, say: getDevice(address = "rtsp://some_address")

        - That searches a filterchain with the member address == "rtsp://some_address"
        - Converts the data to RTSPCameraDevice or USBCameraDevice
        """
        filterchain = self.get(**kwargs)

        if filterchain is None:
            return None

        # get filterchain init parameters that are compatible with RTSPCameraDevice input parameters
        if filterchain.context_type == ContextType.live:

            if "rtsp://" in filterchain.get_address(
            ):  # automatically generated getter for the address member (see multifork.py)
                pars = filterchain.getParDic(
                    RTSPCameraDevice.parameter_defs
                )  # filter out relevant parameters for the device class
                device = RTSPCameraDevice(**pars)
            else:
                pars = filterchain.getParDic(SDPFileDevice.parameter_defs)
                device = SDPFileDevice(**pars)

        elif filterchain.context_type == ContextType.usb:
            pars = filterchain.getParDic(USBCameraDevice.parameter_defs)
            device = USBCameraDevice(**pars)

        else:
            device = None

        print(self.pre, "getDevice :", pars, device)
        return device
Beispiel #3
0
    def getDevice(self, **kwargs):
        """Like get, but returns a Device instance (RTSPCameraDevice, etc.)

        You can pass, say: getDevice(address = "rtsp://some_address")

        - That searches a filterchain with the member address == "rtsp://some_address"
        - Converts the data to RTSPCameraDevice or USBCameraDevice
        """
        filterchain = self.get(**kwargs)

        if filterchain is None:
            return None

        # get filterchain init parameters that are compatible with RTSPCameraDevice input parameters
        if filterchain.context_type == ContextType.live:
            pars = filterchain.getParDic(RTSPCameraDevice.parameter_defs)
            device = RTSPCameraDevice(**pars)
        elif filterchain.context_type == ContextType.usb:
            pars = filterchain.getParDic(USBCameraDevice.parameter_defs)
            device = USBCameraDevice(**pars)
        else:
            device = None

        print(self.pre, "getDevice :", pars, device)
        return device
    def setupUi(self):
        self.setGeometry(QtCore.QRect(100, 100, 500, 500))
        # self.w = self.VideoWidget(self)
        self.w = QtWidgets.QWidget(self)
        self.setCentralWidget(self.w)

        self.root = HeaderListItem()

        self.server1 = ServerListItem(name="First Server",
                                      ip="192.168.1.20",
                                      parent=self.root)
        self.server2 = ServerListItem(name="First Server",
                                      ip="192.168.1.21",
                                      parent=self.root)
        self.server3 = ServerListItem(name="First Server",
                                      ip="192.168.1.22",
                                      parent=self.root)
        self.server4 = ServerListItem(name="First Server",
                                      ip="192.168.1.23",
                                      parent=self.root)

        self.camera1 = RTSPCameraListItem(camera=RTSPCameraDevice(
            _id=1,
            slot=1,
            address="192.168.1.4",
            username="******",
            password="******"),
                                          parent=self.server1)

        self.camera7 = USBCameraListItem(camera=USBCameraDevice(
            _id=1, slot=2, address="/dev/video2"),
                                         parent=self.server4)

        self.treelist = BasicView(parent=None, root=self.root)
        self.treelist.show()
Beispiel #5
0
 def getDevicesById(self):  # , query):
     """
     rows = self.camera_collection.get(query)
     devices_by_id = {}
     for row in rows:
         row.pop("classname")
         device = RTSPCameraDevice(**row)
         devices_by_id[device._id] = device
     return devices_by_id
     """
     rows = self.camera_collection.get()
     devices_by_id = {}
     for row in rows:
         classname = row.pop("classname")
         if (classname == "RTSPCameraRow"):
             device = RTSPCameraDevice(**row)
         elif (classname == "USBCameraRow"):
             device = USBCameraDevice(**row)
         elif (classname == "SDPFileRow"):
             device = SDPFileDevice(**row)
         else:
             device = None
         if (device):
             devices_by_id[device._id] = device
     return devices_by_id
Beispiel #6
0
    def read(self):
        """Reads all devices from the database and creates filterchains
        
        TODO: we can, of course, just modify the added / removed cameras
        """
        self.reset()
        for dic in self.datamodel.camera_collection.get(
        ):  # TODO: search directly for RTSPCameraRow
            if (self.verbose): print(self.pre, "read : dic", dic)
            affinity = -1
            if self.cpu_scheme:
                affinity = self.cpu_scheme.getAV()
            classname = dic.pop("classname")

            if classname == RTSPCameraRow.__name__:
                device = RTSPCameraDevice(
                    **dic)  # a neat object with useful methods
                self.context_type = ContextType.live

            elif classname == USBCameraRow.__name__:
                device = USBCameraDevice(
                    **dic)  # a neat object with useful methods
                self.context_type = ContextType.usb

            elif classname == SDPFileRow.__name__:
                device = SDPFileDevice(
                    **dic)  # a neat object with useful methods
                self.context_type = ContextType.live

            else:
                print(self.pre, "no context for classname", classname)
                continue

            chain = PlaybackFilterchain(  # decoding and branching the stream happens here
                openglthreads=self.gpu_handler.openglthreads,
                # valkkafsmanager  = self.valkkafsmanager,
                slot=device.getRecSlot(),
                _id=device._id,
                affinity=affinity,
                # verbose     = True,
                verbose=False)
            self.chains.append(
                chain
            )  # important .. otherwise chain will go out of context and get garbage collected
Beispiel #7
0
    def ip_list_slot(self, ip_lis):
        self.listitems = []
        self.tree.reset_()

        for ip in ip_lis:
            listitem = RTSPCameraListItem(camera=RTSPCameraDevice(
                _id=0, slot=0, address=ip, username="******", password="******"),
                                          parent=self.root)
            self.listitems.append(listitem)

        self.tree.update()
        self.tree.expandAll()
        self.scan_button.setEnabled(True)
        if len(ip_lis) > 0:
            self.import_button.setEnabled(True)
Beispiel #8
0
    def updateCameraTree(self):
        self.treelist.reset_()

        self.server = ServerListItem(
            name = "Localhost", ip = "127.0.0.1", parent = self.root)
        """
        self.server1 = ServerListItem(
            name="First Server", ip="192.168.1.20", parent=self.root)
        """
        """
        self.camera1 = RTSPCameraListItem(camera=RTSPCameraDevice(
            ip="192.168.1.4", username="******", password="******"), parent=self.server1)
        self.camera2 = RTSPCameraListItem(camera=RTSPCameraDevice(
            ip="192.168.1.4", username="******", password="******"), parent=self.server1)
        """
        devices = []

        for row in singleton.data_model.camera_collection.get():
            # print(pre, "makeCameraTree : row", row)
            if (row["classname"] == RTSPCameraRow.__name__):
                row.pop("classname")
                devices.append(
                    RTSPCameraListItem(
                        camera = RTSPCameraDevice(**row),
                        parent = self.server
                    )
                )
            elif (row["classname"] == USBCameraRow.__name__):
                row.pop("classname")
                devices.append(
                    USBCameraListItem(
                        camera = USBCameraDevice(**row),
                        parent = self.server
                    )
                )
                
        self.treelist.update()
        self.treelist.expandAll()