def setupUi(self): self.setGeometry(QtCore.QRect(100, 100, 800, 800)) self.valkkafs = ValkkaFS.loadFromDirectory( dirname="/home/sampsa/tmp/testvalkkafs") self.manager = ValkkaFSManager(self.valkkafs) self.manager.setOutput_(925412, 1) # id => slot gpu_handler = GPUHandler() pvc = PlayVideoContainerNxM(n_dim=3, m_dim=3, valkkafsmanager=self.manager, gpu_handler=gpu_handler, filterchain_group=None) # dummy window self.w = QtWidgets.QWidget(self) self.setCentralWidget(self.w) self.lay = QtWidgets.QVBoxLayout(self.w)
def setupUi(self): self.setGeometry(QtCore.QRect(100, 100, 800, 800)) self.w = QtWidgets.QWidget(self) self.setCentralWidget(self.w) self.lay = QtWidgets.QVBoxLayout(self.w) self.timelinewidget = TimeLineWidget(datetime.date.today(), parent=self.w) self.timelinewidget.setLogLevel(logging.DEBUG) self.lay.addWidget(self.timelinewidget) self.calendarwidget = CalendarWidget(datetime.date.today(), parent=self.w) self.buttons = QtWidgets.QWidget(self.w) self.buttons_lay = QtWidgets.QHBoxLayout(self.buttons) self.play_button = QtWidgets.QPushButton("play", self.buttons) self.stop_button = QtWidgets.QPushButton("stop", self.buttons) self.buttons_lay.addWidget(self.play_button) self.buttons_lay.addWidget(self.stop_button) self.lay.addWidget(self.buttons) self.lay.addWidget(self.calendarwidget) self.valkkafs = ValkkaFS.loadFromDirectory( dirname="/home/sampsa/tmp/testvalkkafs") self.manager = ValkkaFSManager(self.valkkafs) self.manager.setOutput_(925412, 1) # id => slot self.playback_controller = PlaybackController( calendar_widget=self.calendarwidget, timeline_widget=self.timelinewidget, valkkafs_manager=self.manager, play_button=self.play_button, stop_button=self.stop_button) """
setPyCallback : [int] current mstime, freq: 500 ms setPyCallback2 : [tuple] (min mstimestamp, max mstimestamp) """ #</hide> """<rtf> Same imports as before: <rtf>""" import time from valkka.core import * from valkka.api2 import ValkkaFS, loglevel_debug, loglevel_normal setLogLevel_filelogger(loglevel_debug) """<rtf> Load ValkkaFS metadata: <rtf>""" valkkafs = ValkkaFS.loadFromDirectory(dirname="/home/sampsa/tmp/testvalkkafs") """<rtf> Let's take a look at the blocktable: <rtf>""" a = valkkafs.getBlockTable() print(a[:, 0:10]) """<rtf> Filterchain is going to look like this: :: (ValkkaFSReaderThread:readerthread) -->> (FileCacheThread:cacherthread) --> {InfoFrameFilter:out_filter} | $ setPyCallback : [int] current mstime, freq: 500 ms
from valkka.api2 import ValkkaFS fs = ValkkaFS.loadFromDirectory("fs_directory") fs.analyzer.dumpBlock(1)
def openValkka(self): self.cpu_scheme = CPUScheme() # singleton.data_model.camera_collection try: memory_config = next(singleton.data_model.config_collection.get({"classname" : MemoryConfigRow.__name__})) except StopIteration: print(pre, "Using default mem config") singleton.data_model.writeDefaultMemoryConfig() memory_config = default.get_memory_config() try: valkkafs_config = next(singleton.data_model.valkkafs_collection.get({"classname" : ValkkaFSConfigRow.__name__})) except StopIteration: print(pre, "Using default valkkafs config") singleton.data_model.writeDefaultValkkaFSConfig() valkkafs_config = default.get_valkkafs_config() n_frames = round(memory_config["msbuftime"] * default.fps / 1000.) # accumulated frames per buffering time = n_frames if (memory_config["bind"]): self.cpu_scheme = CPUScheme() else: self.cpu_scheme = CPUScheme(n_cores = -1) self.gpu_handler = GPUHandler( n_720p = memory_config["n_720p"] * n_frames, # n_cameras * n_frames n_1080p = memory_config["n_1080p"] * n_frames, n_1440p = memory_config["n_1440p"] * n_frames, n_4K = memory_config["n_4K"] * n_frames, msbuftime = memory_config["msbuftime"], verbose = False, cpu_scheme = self.cpu_scheme ) self.livethread = LiveThread( name = "live_thread", verbose = False, affinity = self.cpu_scheme.getLive() ) self.usbthread = USBDeviceThread( name = "usb_thread", verbose = False, affinity = self.cpu_scheme.getUSB() ) # see datamodel.row.ValkkaFSConfigRow blocksize = valkkafs_config["blocksize"] n_blocks = valkkafs_config["n_blocks"] fs_flavor = valkkafs_config["fs_flavor"] record = valkkafs_config["record"] # TODO: activate this if ValkkaFS changed in config! if fs_flavor == "file": partition_uuid = None else: partition_uuid = valkkafs_config["partition_uuid"] create_new_fs = False if self.valkkafs is None: # first time create_new_fs = False # try to load initially from disk else: print("openValkka: checking ValkkaFS") create_new_fs = not self.valkkafs.is_same( # has changed, so must recreate partition_uuid = partition_uuid, # None or a string blocksize = blocksize * 1024*1024, n_blocks = n_blocks ) if create_new_fs: print("openValkka: ValkkaFS changed!") if not create_new_fs: # let's try to load it print("openValkka: trying to load ValkkaFS") try: self.valkkafs = ValkkaFS.loadFromDirectory( dirname = singleton.valkkafs_dir.get() ) except ValkkaFSLoadError as e: print("openValkka: loading ValkkaFS failed with", e) create_new_fs = True # no luck, must recreate if create_new_fs: print("openValkka: (re)create ValkkaFS") self.valkkafs = ValkkaFS.newFromDirectory( dirname = singleton.valkkafs_dir.get(), blocksize = valkkafs_config["blocksize"] * 1024*1024, # MB n_blocks = valkkafs_config["n_blocks"], partition_uuid = partition_uuid, verbose = True ) # to keep things consistent.. singleton.data_model.valkkafs_collection.new( ValkkaFSConfigRow, { # "dirname" : default.valkkafs_config["dirname"], # not written to db for the moment "n_blocks" : default.get_valkkafs_config()["n_blocks"], "blocksize" : valkkafs_config["blocksize"], "fs_flavor" : valkkafs_config["fs_flavor"], "record" : record, "partition_uuid" : partition_uuid }) """ else: self.valkkafs = None """ # if no recording selected, set self.valkkafsmanager = None self.valkkafsmanager = ValkkaFSManager( self.valkkafs, write = record, # True or False read = record, cache = record ) self.playback_controller = PlaybackController(valkkafs_manager = self.valkkafsmanager) self.filterchain_group = LiveFilterChainGroup( datamodel = singleton.data_model, livethread = self.livethread, usbthread = self.usbthread, gpu_handler = self.gpu_handler, cpu_scheme = self.cpu_scheme) self.filterchain_group.read() if record: print("openValkka: ValkkaFS **RECORDING ACTIVATED**") self.filterchain_group.setRecording(RecordType.always, self.valkkafsmanager) # self.filterchain_group.update() # TODO: use this once fixed self.filterchain_group_play = PlaybackFilterChainGroup( datamodel = singleton.data_model, valkkafsmanager = self.valkkafsmanager, gpu_handler = self.gpu_handler, cpu_scheme = self.cpu_scheme) self.filterchain_group_play.read() try: from valkka.mvision import multiprocess except ImportError: pass """