Skip to content
Snippets Groups Projects
Commit 1124e522 authored by Andrews Sobral's avatar Andrews Sobral
Browse files

fixed qt project, and fet.py for python3

parent 7dd1613c
Branches
Tags
No related merge requests found
etc/ etc/
build-*/
build_*/ build_*/
dataset_*/ dataset_*/
binaries*/ binaries*/
......
...@@ -51,43 +51,43 @@ video_file = "dataset/video.avi" ...@@ -51,43 +51,43 @@ video_file = "dataset/video.avi"
capture = cv2.VideoCapture(video_file) capture = cv2.VideoCapture(video_file)
while not capture.isOpened(): while not capture.isOpened():
capture = cv2.VideoCapture(video_file) capture = cv2.VideoCapture(video_file)
cv2.waitKey(1000) cv2.waitKey(1000)
print("Wait for the header") print("Wait for the header")
#pos_frame = capture.get(cv2.cv.CV_CAP_PROP_POS_FRAMES) #pos_frame = capture.get(cv2.cv.CV_CAP_PROP_POS_FRAMES)
#pos_frame = capture.get(cv2.CV_CAP_PROP_POS_FRAMES) #pos_frame = capture.get(cv2.CV_CAP_PROP_POS_FRAMES)
pos_frame = capture.get(1) pos_frame = capture.get(1)
while True: while True:
flag, frame = capture.read() flag, frame = capture.read()
if flag: if flag:
cv2.imshow('video', frame) cv2.imshow('video', frame)
#pos_frame = capture.get(cv2.cv.CV_CAP_PROP_POS_FRAMES) #pos_frame = capture.get(cv2.cv.CV_CAP_PROP_POS_FRAMES)
#pos_frame = capture.get(cv2.CV_CAP_PROP_POS_FRAMES) #pos_frame = capture.get(cv2.CV_CAP_PROP_POS_FRAMES)
pos_frame = capture.get(1) pos_frame = capture.get(1)
#print str(pos_frame)+" frames" #print str(pos_frame)+" frames"
img_output = bgs.apply(frame) img_output = bgs.apply(frame)
img_bgmodel = bgs.getBackgroundModel(); img_bgmodel = bgs.getBackgroundModel();
cv2.imshow('img_output', img_output) cv2.imshow('img_output', img_output)
cv2.imshow('img_bgmodel', img_bgmodel) cv2.imshow('img_bgmodel', img_bgmodel)
else: else:
#capture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, pos_frame-1) #capture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, pos_frame-1)
#capture.set(cv2.CV_CAP_PROP_POS_FRAMES, pos_frame-1) #capture.set(cv2.CV_CAP_PROP_POS_FRAMES, pos_frame-1)
#capture.set(1, pos_frame-1) #capture.set(1, pos_frame-1)
#print "Frame is not ready" #print "Frame is not ready"
cv2.waitKey(1000) cv2.waitKey(1000)
break break
if 0xFF & cv2.waitKey(10) == 27: if 0xFF & cv2.waitKey(10) == 27:
break break
#if capture.get(cv2.cv.CV_CAP_PROP_POS_FRAMES) == capture.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT): #if capture.get(cv2.cv.CV_CAP_PROP_POS_FRAMES) == capture.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT):
#if capture.get(cv2.CV_CAP_PROP_POS_FRAMES) == capture.get(cv2.CV_CAP_PROP_FRAME_COUNT): #if capture.get(cv2.CV_CAP_PROP_POS_FRAMES) == capture.get(cv2.CV_CAP_PROP_FRAME_COUNT):
#if capture.get(1) == capture.get(cv2.CV_CAP_PROP_FRAME_COUNT): #if capture.get(1) == capture.get(cv2.CV_CAP_PROP_FRAME_COUNT):
#break #break
cv2.destroyAllWindows() cv2.destroyAllWindows()
...@@ -11,6 +11,10 @@ import os ...@@ -11,6 +11,10 @@ import os
from os import listdir from os import listdir
from os.path import isfile, join from os.path import isfile, join
import sys
if sys.version_info >= (3, 0):
from six.moves import xrange
path_gt = 'GT/' path_gt = 'GT/'
path_fg = 'FG/' path_fg = 'FG/'
path_sc = 'SC/' path_sc = 'SC/'
...@@ -40,54 +44,54 @@ red = [0,0,255] # for FP ...@@ -40,54 +44,54 @@ red = [0,0,255] # for FP
white = [255,255,255] # for TP white = [255,255,255] # for TP
black = [0,0,0] # for TN black = [0,0,0] # for TN
print 'Processing' print('Processing')
k = 1 k = 1
for file_gt, file_fg in zip(files_gt, files_fg): for file_gt, file_fg in zip(files_gt, files_fg):
print(k, file_gt, file_fg) print(k, file_gt, file_fg)
img_gt = cv2.imread(path_gt + file_gt,cv2.IMREAD_GRAYSCALE) img_gt = cv2.imread(path_gt + file_gt,cv2.IMREAD_GRAYSCALE)
img_fg = cv2.imread(path_fg + file_fg,cv2.IMREAD_GRAYSCALE) img_fg = cv2.imread(path_fg + file_fg,cv2.IMREAD_GRAYSCALE)
# img_gt = cv2.resize(img_gt, (0,0), fx=0.5, fy=0.5) # img_gt = cv2.resize(img_gt, (0,0), fx=0.5, fy=0.5)
# print(img_gt.shape,img_fg.shape) # print(img_gt.shape,img_fg.shape)
rows,cols = img_gt.shape rows,cols = img_gt.shape
img_fg = cv2.resize(img_fg,(cols,rows)) img_fg = cv2.resize(img_fg,(cols,rows))
img_res = np.zeros((rows,cols,3),np.uint8) img_res = np.zeros((rows,cols,3),np.uint8)
for i in xrange(rows): for i in xrange(rows):
for j in xrange(cols): for j in xrange(cols):
pixel_gt = img_gt[i,j] pixel_gt = img_gt[i,j]
pixel_fg = img_fg[i,j] pixel_fg = img_fg[i,j]
if(pixel_gt == 255 and pixel_fg == 255): if(pixel_gt == 255 and pixel_fg == 255):
TP = TP + 1 TP = TP + 1
img_res[i,j] = white img_res[i,j] = white
if(pixel_gt == 0 and pixel_fg == 255): if(pixel_gt == 0 and pixel_fg == 255):
FP = FP + 1 FP = FP + 1
img_res[i,j] = red img_res[i,j] = red
if(pixel_gt == 0 and pixel_fg == 0): if(pixel_gt == 0 and pixel_fg == 0):
TN = TN + 1 TN = TN + 1
img_res[i,j] = black img_res[i,j] = black
if(pixel_gt == 255 and pixel_fg == 0): if(pixel_gt == 255 and pixel_fg == 0):
FN = FN + 1 FN = FN + 1
img_res[i,j] = green img_res[i,j] = green
cv2.imshow('GT',img_gt) cv2.imshow('GT',img_gt)
cv2.imshow('FG',img_fg) cv2.imshow('FG',img_fg)
cv2.imshow('SC',img_res) cv2.imshow('SC',img_res)
cv2.imwrite(path_sc + file_gt, img_res) cv2.imwrite(path_sc + file_gt, img_res)
cv2.waitKey(1) # 33 cv2.waitKey(1) # 33
k = k + 1 k = k + 1
#break #break
cv2.destroyAllWindows() cv2.destroyAllWindows()
Recall = TP / (TP + FN) Recall = TP / (TP + FN)
Precision = TP / (TP + FP) Precision = TP / (TP + FP)
Fscore = 2*Precision*Recall/(Precision+Recall) Fscore = 2*Precision*Recall/(Precision+Recall)
print 'Score:' print('Score:')
print 'TP: ', TP print('TP: ', TP)
print 'FP: ', FP print('FP: ', FP)
print 'TN: ', TN print('TN: ', TN)
print 'FN: ', FN print('FN: ', FN)
print 'Recall: ', Recall print('Recall: ', Recall)
print 'Precision: ', Precision print('Precision: ', Precision)
print 'Fscore: ', Fscore print('Fscore: ', Fscore)
print '' print('')
##################################################################### #####################################################################
...@@ -7,3 +7,4 @@ binaries*/ ...@@ -7,3 +7,4 @@ binaries*/
Makefile* Makefile*
*.exe *.exe
*.dll *.dll
*.pro.user
...@@ -27,6 +27,8 @@ set(CMAKE_AUTOUIC ON) ...@@ -27,6 +27,8 @@ set(CMAKE_AUTOUIC ON)
# Find the Qt5Widgets library # Find the Qt5Widgets library
find_package(Qt5Widgets) find_package(Qt5Widgets)
# To fix the issue: https://stackoverflow.com/questions/38557755/cmake-cant-seem-to-find-needed-qt-cmake-files-even-though-ive-set-cmake-prefix
#find_package(Qt5Widgets CONFIG PATHS C:/Qt/5.11.1/msvc2017_64/lib/cmake NO_DEFAULT_PATH)
if(Qt5Widgets_FOUND) if(Qt5Widgets_FOUND)
message(STATUS "Qt5Widgets status:") message(STATUS "Qt5Widgets status:")
message(STATUS " version: ${Qt5Widgets_VERSION}") message(STATUS " version: ${Qt5Widgets_VERSION}")
......
...@@ -16,8 +16,13 @@ TEMPLATE = app ...@@ -16,8 +16,13 @@ TEMPLATE = app
#LIBS += -LC:/OpenCV3.1.0/build/x64/vc14/lib -lopencv_world310 #LIBS += -LC:/OpenCV3.1.0/build/x64/vc14/lib -lopencv_world310
# For Windows x64 + Visual Studio 2015 + OpenCV 3.2.0 # For Windows x64 + Visual Studio 2015 + OpenCV 3.2.0
INCLUDEPATH += C:/OpenCV3.2.0/build/include #INCLUDEPATH += C:/OpenCV3.2.0/build/include
LIBS += -LC:/OpenCV3.2.0/build/x64/vc14/lib -lopencv_world320 #LIBS += -LC:/OpenCV3.2.0/build/x64/vc14/lib -lopencv_world320
# For Windows x64 + Visual Studio 2017 + OpenCV 3.4.2
INCLUDEPATH += E:/OpenCV3.4.2/build/include
INCLUDEPATH += E:/OpenCV3.4.2/build/include/opencv
LIBS += -LE:/OpenCV3.4.2/build/x64/vc15/lib -lopencv_world342
# For Linux # For Linux
# INCLUDEPATH += /usr/local/include/opencv # INCLUDEPATH += /usr/local/include/opencv
...@@ -124,7 +129,8 @@ SOURCES += bgslibrary_gui.cpp\ ...@@ -124,7 +129,8 @@ SOURCES += bgslibrary_gui.cpp\
../package_bgs/VuMeter.cpp \ ../package_bgs/VuMeter.cpp \
../package_bgs/WeightedMovingMean.cpp \ ../package_bgs/WeightedMovingMean.cpp \
../package_bgs/WeightedMovingVariance.cpp \ ../package_bgs/WeightedMovingVariance.cpp \
../package_bgs/_template_/amber/amber.c ../package_bgs/_template_/amber/amber.c \
../package_bgs/CodeBook.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
qt_utils.h \ qt_utils.h \
...@@ -236,7 +242,8 @@ HEADERS += mainwindow.h \ ...@@ -236,7 +242,8 @@ HEADERS += mainwindow.h \
../package_bgs/ViBe.h \ ../package_bgs/ViBe.h \
../package_bgs/VuMeter.h \ ../package_bgs/VuMeter.h \
../package_bgs/WeightedMovingMean.h \ ../package_bgs/WeightedMovingMean.h \
../package_bgs/WeightedMovingVariance.h ../package_bgs/WeightedMovingVariance.h \
../package_bgs/CodeBook.h
FORMS += mainwindow.ui FORMS += mainwindow.ui
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment