Comments (2)
Hi, you say your result 10.8 is lower than 9.0? That seems like a higher number (error) to me.
It will be almost impossible after so long reconstruct what exactly is the difference.
However, if it helps, I am attaching our Columbia preprocessor. However, I do not guarantee this is the final correct version of the code.
It seems we do not have minus in the gaze[0] equation (so our yaw goes the other way around).
`
import sys; sys.path.insert(0, '.')
import numpy as np
import sys, os, re, time, json, glob, math, argparse
import pickle
import cv2
import scipy.io as sio
import scipy.interpolate as sci
import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as plt
def angles2Dir(angles):
gaze3d = np.zeros([angles.shape[0], 3], angles.dtype)
gaze3d[:,0] = np.sin(angles[:,0]) * np.cos(angles[:,1])
gaze3d[:,2] = -np.cos(angles[:,0]) * np.cos(angles[:,1])
gaze3d[:,1] = np.sin(angles[:,1])
return gaze3d
class ColumbiaCompiler(object):
def __init__(self):
super(ColumbiaCompiler, self).__init__()
def run(self, exportImages = False):
baseDir = os.path.join(myglobals.DATASETS_PATH, 'Columbia')
outputPath = dataset_tools.preparePath(os.path.join(baseDir, 'compiled'))
print('[ColumbiaCompiler] Processing %s...' % baseDir)
subjectsPath = os.path.join(baseDir, 'Columbia Gaze Data Set')
subjectDirs = os.listdir(subjectsPath)
subjectDirs = np.array(subjectDirs, np.object)
subjectDirs.sort()
meta = {
'subject': [],
'filename': [],
'distance_m': [],
'hp_deg': [],
'gaze_cam_deg': [],
'gaze_dir': [],
'face_bbox': [],
}
faceBbox = np.array([(5184 - 2800) // 2, 330, 2800, 2800], np.float32) / [5184, 3456, 5184, 3456]
for i,subjectName in enumerate(subjectDirs):
subjectPath = os.path.join(subjectsPath, subjectName)
if not os.path.isdir(subjectPath):
continue
print('\tAdding %s [%d/%d]...' % (subjectName, i, len(subjectDirs)))
subjectId = int(re.match('(\d+)$', subjectName).group(1))
# Enum frames
files = os.listdir(subjectPath)
files = np.array(files, np.object)
files.sort()
for j,file in enumerate(files):
imPath = os.path.join(subjectPath, file)
if not re.match('.*\.jpg$', file) or not os.path.isfile(imPath):
continue
print('\t\t[%d/%d] [%d/%d] %s...' % (i, len(subjectDirs), j, len(files), file))
# Gaze data
m = re.match('(\d+)\_(\d+)m\_([\-\d]+)P\_([\-\d]+)V\_([\-\d]+)H\.jpg$', file)
distance = float(m.group(2))
pose = np.array([-float(m.group(3)), 0], np.float32)
gazeCamDeg = np.array([-float(m.group(5)), float(m.group(4))], np.float32)
gazeCam = dataset_tools.angles2Dir(gazeCamDeg.reshape(1,2) / 180 * math.pi)[0,:]
meta['subject'] += [subjectId]
meta['filename'] += [file]
meta['distance_m'] += [distance]
meta['hp_deg'] += [pose]
meta['gaze_cam_deg'] += [gazeCamDeg]
meta['gaze_dir'] += [gazeCam]
meta['face_bbox'] += [faceBbox]
# Crop face image
if exportImages:
im = cv2.imread(imPath)
imFace = image_tools.cropImage(im, faceBbox)
imFaceLow = cv2.resize(imFace, (800, 800), interpolation=cv2.INTER_AREA)
#cv2.imshow('imFaceLow', imFaceLow)
#cv2.waitKey(0)
imFaceDir = dataset_tools.preparePath(os.path.join(outputPath, 'face', '%04d' % subjectId))
cv2.imwrite(os.path.join(imFaceDir, file), imFaceLow, [cv2.IMWRITE_JPEG_QUALITY, 95])
meta['filename'] = np.array(meta['filename'], np.object)
outputMetaFile = os.path.join(outputPath, 'metadata.mat')
sio.savemat(outputMetaFile, meta)
print('DONE')
def readFaceImage(self, imFilename):
im = cv2.imread(imFilename)
imMax = np.max(im, axis=2)
mask = imMax > 20
inds = np.argwhere(mask)
aa = np.min(inds, axis=0)
bb = np.max(inds, axis=0) + 1
aaBB = np.concatenate([aa[::-1], bb[::-1] - aa[::-1]]).astype(np.float32) / [im.shape[1], im.shape[0], im.shape[1], im.shape[0]]
#crop = im[aa[0]:bb[0],aa[1]:bb[1],:]
crop = image_tools.cropImage(im, aaBB)
#cv2.imshow('im', im)
#cv2.imshow('crop', crop)
#cv2.waitKey(0)
return crop, aaBB
def vizualize(self):
dsDir = os.path.join(myglobals.DATASETS_PATH, 'Columbia', 'compiled')
meta = dataset_tools.loadMetadata(os.path.join(dsDir, 'metadata.mat'))
subjectId = 53
mask = meta['subject'] == subjectId
inds = np.argwhere(mask).flatten()
for i,ind in enumerate(inds):
filename = meta['filename'][ind]
imFile = os.path.join(dsDir, 'face', '%04d' % subjectId, filename)
gaze = meta['gaze_dir'][ind,:]
#gaze = meta['orig_gaze'][ind,:] * [-1,-1,1]
print('[%d/%d] %s | Gaze = %s' % (i, len(inds), imFile, np.array2string(gaze)))
# Render
im = cv2.imread(imFile)
gaze = gaze * [-1,1,1]
VizTools.drawGazeDirs(im, gaze.reshape(1,-1), [(0,249,255)], np.array([[0.5, 0.5]]), [[2.0, 2.0]])
# Present
cv2.imshow('Face', im)
if cv2.waitKey(0) & 0xff == 27:
break
if name == "main":
ex = ColumbiaCompiler()
#ex.run()
ex.vizualize()
`
from gaze360.
Your suggestion effectively helps me.
With reference to your data processor, I found that the problem lies in the image used. In the previous experiments, I used the raw image from the Columbia. After the image was cropped, the cross-dataset evolution result returned to the normal value.
Thanks a lot.
from gaze360.
Related Issues (20)
- some question about the code HOT 2
- some question about camera calibration HOT 1
- Definition of yaw and pitch HOT 3
- DATASET ACCESS INFORMATION
- how to present the predicted result
- some question about generate ground truth HOT 6
- some error in the traindata HOT 5
- some problem about the predict HOT 9
- An error occurred in the test results HOT 1
- some error in the HOT 1
- Cross dataset evaluation HOT 1
- How to get mean angular errors HOT 1
- how to get gaze label? HOT 1
- Could you tell me setting of gaze360 V2?
- Pitch Yaw angels
- Camera Intrinsics ?
- the range of front 20
- Colab Notebook V2 is not working - Lucid Error
- Unable to download the dataset
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gaze360.