Exemplo n.º 1
0
Arquivo: eco.py Projeto: mazent/varie
    def _fine_x_errore(self, quanti):
        self.progBar.start(10)

        conta = 0
        tot = 0

        self.crono.conta()
        while conta < quanti and self.continua:
            tot += 1

            if not self._esegui():
                conta += 1

        durata = self.crono.durata()
        self.continua = False
        self.timerEco.termina()
        del self.timerEco
        self.timerEco = None
        sdurata = utili.stampaDurata(int(round(durata * 1000.0, 0)))

        if conta == 0:
            self._stampa_bene(tot, durata, sdurata)
        else:
            self.msg.set(
                "Eco: %d errori su %d [%s]" %
                (conta, tot, sdurata))

        self.progBar.stop()
        self.bottone["text"] = self.testo
        if self.codaf is not None:
            self.codaf.put((self.msgFineEco,))
Exemplo n.º 2
0
    def _leggi_foto_(self, dummy):
        colonne = 1280
        righe = 800

        tinizio = time.clock()
        bayer = self.dispo.cameraX()
        durata = time.clock() - tinizio

        if bayer is None:
            gui_support.Messaggio.set("Camera: ERRORE")
        elif len(bayer) != righe * colonne:
            gui_support.Messaggio.set("Camera: ERRORE (dati)")
        else:
            sdurata = utili.stampaDurata(int(round(durata * 1000.0, 0)))
            kib = round(len(bayer) / (durata * 1024), 1)
            print("%d B in %s = %d KiB/s" % (len(bayer), sdurata, kib))

            img = np.ndarray((righe, colonne), dtype='uint8', buffer=bayer)

            rgb = cv2.cvtColor(img, cv2.COLOR_BayerBG2RGB)
            nomefoto = 'pippo.png'
            cv2.imwrite(nomefoto, rgb)

            # Mostro
            cv2.namedWindow('foto', cv2.WINDOW_NORMAL)
            cv2.imshow('foto', rgb)
            cv2.waitKey(0)
            cv2.destroyAllWindows()

            gui_support.Messaggio.set("Camera: OK (" + nomefoto + ")")
Exemplo n.º 3
0
Arquivo: eco.py Projeto: mazent/varie
    def _Finito(self, quanti):
        self.progBar.start(10)

        conta = 0
        tot = 0

        self.crono.conta()
        while tot < quanti and self.continua:
            tot += 1

            if self._esegui():
                conta += 1

        durata = self.crono.durata()
        self.continua = False
        self.timerEco.termina()
        del self.timerEco
        self.timerEco = None
        sdurata = utili.stampaDurata(int(round(durata * 1000.0, 0)))

        if conta == tot:
            self._stampa_bene(tot, durata, sdurata)
        elif conta == 0:
            self.msg.set("Eco: ERR %d in %s" % (tot, sdurata))
        else:
            self.msg.set(
                "Eco: OK %d / %d in %s" %
                (conta, tot, sdurata))

        self.progBar.stop()
        self.bottone["text"] = self.testo
        if self.codaf is not None:
            self.codaf.put((self.msgFineEco,))
Exemplo n.º 4
0
    def aggiornaEco(self):
        if self.continuaEco:
            self.ecoMux.acquire()
            durata = time.clock() - self.ecoInizio
            self.ecoMux.release()

            self.msg.set(utili.stampaDurata(int(round(durata * 1000.0, 0))))

            self.timerEco = self.bottone.after(self.durataTimer,
                                               self.aggiornaEco)
        else:
            self.bottone.after_cancel(self.timerEco)
Exemplo n.º 5
0
    def ecoFinito(self, quanti, dispo):
        dati = self._genera_dati(dispo)
        dato = dati[0]

        self.progBar.start(10)

        self.ecoConta = 0
        self.ecoTot = 0
        tot = 0

        self.ecoInizio = time.clock()

        while self.ecoTot < quanti and self.continuaEco:
            self.ecoMux.acquire()

            self.ecoTot += 1
            if dispo.Eco(dato):
                self.ecoConta += 1
                tot += len(dato)

            self.ecoMux.release()

            if dato is dati[0]:
                dato = dati[1]
            else:
                dato = dati[0]

        self.continuaEco = False
        durata = time.clock() - self.ecoInizio
        sdurata = utili.stampaDurata(int(round(durata * 1000.0, 0)))

        if self.ecoConta == self.ecoTot:
            milli = round(1000.0 * durata / self.ecoConta, 3)
            tput = round(tot / durata, 1)
            kib = round(tot / (durata * 1024), 1)
            self.msg.set("Eco: OK %d in %s (%.3f ms = %.1f B/s = %.1f KiB/s)" %
                         (self.ecoConta, sdurata, milli, tput, kib))
        elif 0 == self.ecoConta:
            self.msg.set("Eco: ERR %d in %s" % (self.ecoTot, sdurata))
        else:
            self.msg.set("Eco: OK %d / %d in %s" %
                         (self.ecoConta, self.ecoTot, sdurata))

        self.progBar.stop()
        self.bottone["text"] = "Eco"
Exemplo n.º 6
0
    def ecoInfinito(self, dispo):
        dati = self._genera_dati(dispo)
        dato = dati[0]

        self.progBar.start(10)

        self.ecoConta = 0
        self.ecoTot = 0

        self.ecoInizio = time.clock()

        while self.continuaEco:
            self.ecoMux.acquire()

            self.ecoTot += 1
            if dispo.Eco(dato):
                self.ecoConta += 1

            self.ecoMux.release()

            if dato is dati[0]:
                dato = dati[1]
            else:
                dato = dati[0]

        durata = time.clock() - self.ecoInizio
        sdurata = utili.stampaDurata(int(round(durata * 1000.0, 0)))

        if self.ecoConta == self.ecoTot:
            milli = round(1000.0 * durata / self.ecoConta, 3)
            self.msg.set("Eco: OK %d in %s (%.3f ms)" %
                         (self.ecoConta, sdurata, milli))
        elif 0 == self.ecoConta:
            self.msg.set("Eco: ERR %d in %s" % (self.ecoTot, sdurata))
        else:
            self.msg.set("Eco: OK %d / %d in %s" %
                         (self.ecoConta, self.ecoTot, sdurata))

        self.progBar.stop()
        self.bottone["text"] = "Eco"
Exemplo n.º 7
0
    def _leggi_bayer(self, dim, inizio=0):
        bayer = bytearray()

        self.dispo.Cambia(tempo=.1)

        # cinema
        gui_support.leggiFoto.set(0)
        tinizio = time.clock()

        DIM_TOT = dim

        while dim:
            dati = self.dispo.cameraLeggi(len(bayer) + inizio)
            if dati is None:
                dati = self._riprova_bayer(len(bayer) + inizio, dim)
                if dati is None:
                    bayer = None
                    break

            letti = len(dati)
            if letti == 0:
                bayer = None
                break
            if letti > dim:
                dati = dati[:dim]

            bayer += dati
            dim -= len(dati)
            gui_support.leggiFoto.set(100 * len(bayer) / DIM_TOT)

        # cinema
        durata = time.clock() - tinizio
        sdurata = utili.stampaDurata(int(round(durata * 1000.0, 0)))
        kib = round(DIM_TOT / (durata * 1024), 1)
        print("%d B in %s = %d KiB/s" % (DIM_TOT, sdurata, kib))

        self.dispo.Ripristina()

        return bayer
Exemplo n.º 8
0
    def ecoFinePerErrore(self, quanti, dispo):
        dati = self._genera_dati(dispo)
        dato = dati[0]

        self.progBar.start(10)

        self.ecoConta = 0
        self.ecoTot = 0

        self.ecoInizio = time.clock()

        while self.ecoConta < quanti and self.continuaEco:
            self.ecoMux.acquire()

            self.ecoTot += 1
            if not dispo.Eco(dato):
                self.ecoConta += 1
            self.ecoMux.release()

            if dato is dati[0]:
                dato = dati[1]
            else:
                dato = dati[0]

        self.continuaEco = False
        durata = time.clock() - self.ecoInizio
        sdurata = utili.stampaDurata(int(round(durata * 1000.0, 0)))

        if 0 == self.ecoConta:
            milli = round(1000.0 * durata / self.ecoTot, 3)
            self.msg.set("Eco: OK %d in %s (%.3f ms)" %
                         (self.ecoTot, sdurata, milli))
        else:
            self.msg.set("Eco: %d errori su %d [%s]" %
                         (self.ecoConta, self.ecoTot, sdurata))

        self.progBar.stop()
        self.bottone["text"] = "Eco"
Exemplo n.º 9
0
Arquivo: eco.py Projeto: mazent/varie
 def _msg_durata(self):
     if self.continua:
         durata = self.crono.durata()
         self.msg.set(utili.stampaDurata(int(round(durata * 1000.0, 0))))