/usr/share/pyshared/pymecavideo/label_auto.py is in python-mecavideo 6.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | #-*- coding: utf-8 -*-
"""
videotraj, a module for pymecavideo:
a program to track moving points in a video frameset
Copyright (C) 2007 Jean-Baptiste Butet <ashashiwa@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import sys, os, thread, time, commands
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from vecteur import vecteur
class Label_Auto(QLabel):
def __init__(self, parent,app):
"""make a rectangle near point to be tracked"""
QLabel.__init__(self, parent)
self.parent = parent
self.setGeometry(QRect(0,0,640,480))
self.setAutoFillBackground(False)
self.app = app
self.setCursor(Qt.CrossCursor)
self.setMouseTracking(True)
def mousePressEvent(self, event):
self.setMouseTracking(False)
self.x_1 = event.x()
self.x_2 = event.x()
self.y_1 = event.y()
self.y_2 = event.y()
def mouseMoveEvent(self, event):
x= event.x()
y = event.y()
if not self.hasMouseTracking():
if x > self.x_1 :
self.x_2 = x
elif x< self.x_1:
self.x_1 = x
if y > self.y_1 :
self.y_2 = y
elif y< self.y_1:
self.y_1 = y
self.app.label_video.zoom_croix.show()
self.pos=vecteur(x,y)
self.app.label_video.fait_crop(self.pos)
self.app.ui.label_zoom.setPixmap(self.app.label_video.cropX2)
self.update()
def mouseReleaseEvent(self,event):
self.app.zoom = True
self.app.motif.append(self.getMotif())
self.app.emit(SIGNAL('selection_motif_done()'))
def getMotif(self):
"""
récupère le motif qui servira à la reconnaissance automatique
sur les images successives.
@result une QImage représentant le motif.
"""
#dimension_motif=20
#rectangle = QRect((self.x_1+self.x_2-dimension_motif)/2,(self.y_1+self.y_2-dimension_motif)/2,dimension_motif,dimension_motif)
rectangle = QRect(self.x_1,self.y_1,self.x_2-self.x_1,self.y_2-self.y_1)
return self.app.image_640_480.copy(rectangle)
def paintEvent(self, event):
if not self.hasMouseTracking():
painter = QPainter()
painter.begin(self)
painter.setPen(Qt.green)
#painter.setBrush(Qt.Dense6Pattern)
painter.drawRect(self.x_1,self.y_1,self.x_2-self.x_1,self.y_2-self.y_1)
painter.end()
|