Skip to content

Conversation

@nazabic
Copy link
Contributor

@nazabic nazabic commented Nov 7, 2017

No description provided.

:param value: an optional value to be save for this ROI (e.g. to define left and right side)
:param orientation: Optional orientation Not implemented yet
:param regions: Optional sub-regions within the ROI. Not implemented yet
:param regions: Optional sub-regions within the ROI.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make it clear, in the doc, that regions is a 2d array and that regions is a greyscale map / LUT. I.e. each pixel is the value of region in X,Y

if gray_value is None:
return 0
else:
print gray_value, self.idx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove print

out += oy
return YPosVariable(out)

class RegionPosVariable(BaseIntVariable):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to RegionValueVariable: Pos suggest we are dealing with a position

phi_var = PhiVariable(int(round(angle)))
# mlogl = mLogLik(int(distance*1000))

gray_region = self._roi.find_region(x_var, y_var)
Copy link
Member

@qgeissmann qgeissmann Nov 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great idea, gray -> grey

self._regions = regions
else:
self._regions = self._mask
logging.warning('The regions argument of the roi has to be an numpy.ndarray that has equal size with the mask of the roi')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make error instead:

logging.error("xxxx")
raise Exception("Regions and Mask hvae different sizes!")


if regions is None:
self._regions = self._mask
elif (regions.size == self._mask.size) & (type(regions) == type(self._mask)):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ndarray.shape to do all in one go

def find_region(self, x, y):
try:
gray_value = self._regions[x, y]
except:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always print exception as a warning:

 try:
    gray_value = self._regions[x, y]
except Exception as e:
    logging.warning(e)
    ...

Also you can specify the type of exceptions Expect IndexError as e.

"""
Type encoding a region inside the ROI, represented as the grayscale value of the pixel on which sits the center of the detected object.
"""
header_name = "gray_region"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

header_name = "sub_roi"

Type encoding a region inside the ROI, represented as the grayscale value of the pixel on which sits the center of the detected object.
"""
header_name = "gray_region"
functional_type = "color"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functional_type = "grey_value" (UK spelling :D)


from ethoscope.utils.description import DescribedObject
import os
import numpy as np
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if unneeded

return out, self._mask
return out, self._mask

def find_region(self, x, y):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to find_sub_region

:param orientation: Optional orientation Not implemented yet
:param regions: Optional sub-regions within the ROI. Not implemented yet
:param regions: Optional sub-regions within the ROI.
:type regions: :class:`~numpy.ndarray`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to subregions

Copy link
Member

@qgeissmann qgeissmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

almost there!!!

elif sub_rois.shape == self._mask.shape:
self._sub_rois = sub_rois
else:
self._sub_rois = self._mask
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this line

def find_sub_roi(self, x, y):
try:
grey_value = self._sub_rois[x, y]
except Exception, e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except Exception as e:

out += oy
return YPosVariable(out)

class SubRoiValueVariable(BaseIntVariable):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a new base class: BaseTinyIntVariable, and derive SubRoiValueVariable from it.
Also, verify that you can store a unsigned (8b)int inside. "TINYINT UNSIGNED" ? check that SQLite supports it (not only MySQL).

_, oy = roi.offset
out += oy
return YPosVariable(out)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, put these variables in your tracker class file ;)

return [out]


class AdaptiveBGModelExtraObjectPosInfo(AdaptiveBGModel):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make another file for this one class

cv2.ellipse(img,((pos["x"],pos["y"]), (pos["w"],pos["h"]), pos["phi"]),colour,1, LINE_AA)


class SubRoiDrawer(BaseDrawer):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should put your new drawer in another file ;)

@ggilestro ggilestro closed this Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants