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