2.1. Edge Visibility Criteria and Camera Configuration
The proposed volumetric reconstruction method uses silhouettes of an object and provides its volumetric reconstruction. The completeness of the reconstructed volume depends to some parameters such as the positions of cameras within the network, number of cameras and the shape of the object.
Figure 1a shows an exemplary case where a convex polygon is observed by two cameras (top view). In this case, the polygon has five edges and five vertices (pentagon), however, as is shown in
Figure 1b, it is registered on the inertial plane as a six edge polygon, due to the effect of the mentioned parameters (number of cameras and their positions). The extra part of the polygon after registration is shown in red in the figure. As previously mentioned, registration of the cross section of an object with an inertial plane can be thought of as the intersection among all shadows created by cameras, through considering each camera as a light source. Based on this interpretation, the appearance of the red part can be justified: the red part is the area which can not be seen by any camera and is shadowed in all views. We intend to introduce a geometric approach to realize the visibility or invisibility of an edge. Assume a general convex polygon including
k vertices
and
k edges
(e.g., consider
Figure 2 as an exemplary polygon corresponding to
Figure 1). A normal vector can be considered for each edge resulting in
. Lets assume a set of
cameras
. We see that the normal vector
at an edge
can be used to identify visibility from a camera
. Each camera
has a pair of tangents (bounding vectors)
to the polygon and for each tangents pair a bisecting vector
is considered. Having this, the visibility criteria for the edges can be expressed as following: an edge
is visible if and only if there is a
where
, see Algorithm 1. For example, in
Figure 2 camera
sees edges
, and
and the normals
,
make angles greater than
with
(clockwise angles). Similarly, camera
‘sees‘ edges
, and
and the normals
,
make angles greater than
with
(clockwise angles). The edge
is not visible in either of the cameras and its normal
makes angles less than
with both bisectors
,
. Thus, Algorithm 1 classifies the edges visibility for a give object.
Figure 1.
Investigation of the criteria for visibility of a general convex polygon. (a) An exemplary convex polygon is being observed by two cameras. The images are shown from the top view of the inertial reference plane . (b) The registration of the polygon corresponding to left picture. The registration includes the object and some extra areas (coloured in red) which do not belong to the polygon. This red area has appeared because of not having visibility on the lowest edge of the polygon.
Figure 1.
Investigation of the criteria for visibility of a general convex polygon. (a) An exemplary convex polygon is being observed by two cameras. The images are shown from the top view of the inertial reference plane . (b) The registration of the polygon corresponding to left picture. The registration includes the object and some extra areas (coloured in red) which do not belong to the polygon. This red area has appeared because of not having visibility on the lowest edge of the polygon.
Figure 2.
The figure shows the involved vectors. Green vectors, and , respectively, indicate the left and right tangents (bounding vectors) of a camera . The bisector vector for each camera bounding pair (the tangents) of and is shown in red (). stands for the normal of the edge . After performing the registration process based on the proposed algorithm, the area colored in red also become registered as a part of the object.
Figure 2.
The figure shows the involved vectors. Green vectors, and , respectively, indicate the left and right tangents (bounding vectors) of a camera . The bisector vector for each camera bounding pair (the tangents) of and is shown in red (). stands for the normal of the edge . After performing the registration process based on the proposed algorithm, the area colored in red also become registered as a part of the object.
ALGORITHM 1: Criteria to check the edges visibility for a given polygon. k is number of polygon’s edges and is the j’th edge.
is the normal vector corresponding to . is the bisecting vector for camera i. Each edge is checked and will be labelled as either ‘visible’ or ‘invisible’. Labelled as ‘invisible’ for an edge means that it is invisible for all the cameras. |
![Jsan 04 00293 i001]() |
2.2. Optimal Camera Placement Using Genetic Algorithm
The visibility criteria defined in Algorithm 1 can be used for obtaining an optimal solution for camera placement. The question to be solved is as following: given a convex polygon with k vertices and k edges and number of cameras, what would be an optimal solution for placements of cameras in order to have the best observation of the polygon for applying the proposed reconstruction method. This question can be considered in another form: Given a polygonal space to be monitored by a camera network, what would be an optimal solution to place n cameras around the space. Genetic algorithms (GA) are bio-inspired algorithms, which are known as appropriate mechanisms to solve such a problem. We continue to describe our GA-based algorithm to solve the mentioned problem.
Population in GA is a set of members called
chromosome. Each chromosome includes a number of elements named
gene. Note that, in our case, a gene is equivalent to a camera and its properties and a chromosome is synonymous to a set of cameras. The structure of a chromosome string is defined in the
Table 1. In this structure
and
stands for the vectors of position and bisector of the camera,
fov is the angle of field-of-view (FOV) and
cost is an scaler value corresponding to the gene’s cost. Based on these definitions, an algorithm to generate a valid gene is provided in Algorithm 2. The inputs of the algorithm are the vector of vertices of the given polygon,
, the search space of the camera positions and maximum possible FOV. Algorithm 3 presents a function to generate a chromosome including
genes (a chromosome string with length =
).
Table 1.
Structure of a chromosome string.
Table 1.
Structure of a chromosome string.
Chromosome |
---|
gene(1) | gene(2) | ... | gene() |
---|
| fov | | cost | | fov | | cost | ... | | fov | | cost |
ALGORITHM 2: Algorithm to generate a valid gene. is the matrix of vertices of the polygon. max_fov is the maximum possible FOV for each gene (camera) and ‘space’ is the search space. Having these as the inputs, the algorithm generates a valid gene with its properties. The position of each gene signifies the position of the corresponding camera. The function getTangentsToPolygon(V,p) receives the matrix of the vertices of the polygon () and the position () of the camera (gene) and returns two vectors ( and ) which are tangents to the given polygon. Then, the angular bisecting vector is stored in . This bisecting vector will be used to compute the cost value of the gene. It can be also interpreted as the looking direction of the camera. Then the generated gene is returned as the result of the function createGene() |
![Jsan 04 00293 i002]() |
One of the crucial points in GA-based algorithms is to have a suitable cost function in order to evaluate the fitness of a member in the population. In the case of our coverage problem, a cost function
is defined (see
Figure 4) for a bisector
and the normal of an edge
as following:
Figure 3.
Defined function to measure the cost between a camera and a polygon edge. The maximum cost is equal to λ and happens when or in other words the edge is invisible by the camera.
Figure 3.
Defined function to measure the cost between a camera and a polygon edge. The maximum cost is equal to λ and happens when or in other words the edge is invisible by the camera.
ALGORITHM 3: Algorithm to generate a chromosome. is the matrix of vertices of the polygon. indicates the chromosome’s length or in other words the number of cameras. max_fov is the maximum possible FOV for each gene (camera) and ‘space’ is the search space. Given these as inputs, the algorithm generate a chromosome with genes and returns it (using Algorithm 2). |
![Jsan 04 00293 i003]() |
One of the crucial points in GA-based algorithms is to have a suitable cost function in order to evaluate the fitness of a member in the population. In the case of our coverage problem, a cost function
is defined (see
Figure 4) for a bisector
and the normal of an edge
as following:
Figure 4.
Defined function to measure the cost between a camera and a polygon edge. The maximum cost is equal to λ and happens when or in other words the edge is invisible by the camera.
Figure 4.
Defined function to measure the cost between a camera and a polygon edge. The maximum cost is equal to λ and happens when or in other words the edge is invisible by the camera.
where
and
α is the angle among the two vectors
and
. An algorithm to compute the cost of each gene in a chromosome string using the defined cost function in Equation (
1) is proposed in Algorithm 4. Firstly, the cost among each individual gene of the chromosome and each edge of the polygon is computed (We chose
in our algorithm and simulations reported here, any value between
can be used and we observed similar convergence rates.) (the whole algorithm except line 0-0, the innermost
if loop). The primary costs for each gene and the polygon’s edges were obtained regardless of considering the other genes in the chromosome. Secondly, the cost of each gene gets updated by taking into account the previous genes in the chromosome, in order to avoid getting trapped in a local minima (line 0-0).
Figure 5 shows an exemplary case where a triangular polygon is supposed to be optimally observed by three cameras. Based on the cost function in Equation (
1) (the second part of Algorithm 4) an optimal arrangement for the cameras is when all three cameras observe the edge
(
denotes the edge connecting vertix
to vertix
). In this situation the cost value for each camera is close to zero (using Equation (
1)), since the angle among the bisector vector of the cameras and
(normal of
) is straight (
π). This case is considered as a local minima for the camera placement. In order to avoid the GA to fall into such a local minima, an update on the cost of each gene in a chromosome with regards to the other genes in the same chromosome is proposed in line 0-0 of Algorithm 4. In this part, the cost of each gene-edge gets increased (penalized) if the same edge was previously observed by another antecedent gene in the chromosome. In this case, the unidirectionality between the bisector vectors of such two genes (
and
for the current gene and the antecedent one) determines the penalty value to be augmented to the cost value of the second gene. The more aligned in the same directions, the more penalty value is applied by using the following equation:
This causes the genes who are observing the same edges get far from each other and converge other edges.
ALGORITHM 4: Algorithm to compute the cost of a chromosome and its genes. The inputs are , the vertices’s matrix and chromosome. The cost value among each individual gene in the chromosome and each edge of the polygon is computed using the Equation (1). The cost value gets penalized for the genes which are visiting an edge that was previously visited by an antecedent gene of the chromosome (line 0-0). The penalty value is obtained using Equation (2). |
![Jsan 04 00293 i004]() |
A genetic algorithm (Algorithm 5) to search for an optimal solution is proposed in this section by using the defined cost function and the introduced sub-functions (Algorithms 2–4). The inputs for this algorithm are: V, the matrix of vertices; , maximum for the FOV of a camera (a gene); , number of cameras (number of genes in a chromosome or chromosome’s length); and ’space’, the space to be searched by GA for placing cameras (search space). Number of population (number of chromosomes) is considered as 100. First a new generation is initialized. After applying a fitness function on each individual (chromosomes) in this population, 20% of them are selected as elites for the new generation. The rest of the population (80%) are created by applying crossover and mutation operations on the elites. For doing so, every time two parents are selected randomly from the elites. Then, a crossover operation is applied in this selected couple and as the result two children (new member of the society or chromosomes) are added to the population. On some of the newly created children, a mutation is applied as well. The probability of happening a mutation on the children is considered as . In each cycle, the cost value of the best member (best fitted chromosome) of the elites is saved as the minimum cost value of that generation. If after a number of consecutive trials the cost value does not get improved, or the algorithm reaches its maximum iteration () then it stops. The answer of the algorithm is an optimal chromosome. This optimal solution includes a set of genes ( genes) and each gene signifies a camera with its properties such as position, direction vector, etc.
Although the proposed algorithm to optimize the camera coverage is discussed in 2D as a case-study, however it has the potential to be used in 3D with some small modifications.
Figure 6 indicates a case where a semi-cube is demonstrated as an exemplary 3D polygon in a 3D space. The first necessary modification in the algorithm to deal with a 3D case is that instead of using the normal vectors of the edges, the normal vectors of the faces have to be used. This counts all faces except the bottom face, which does not need to be observed. The second needed modification is to consider the camera position as 3D instead of 2D, e.g., in Algorithm 2, the place where a camera position in space is randomly created it should be generated as 3D vector. The rest of the algorithm would be the same as the studied 2D case.
Figure 5.
The local minima problem for a triangular polygon and three cameras. Using just the cost value for each gene (camera) regardless of the other genes (cameras) in the same chromosome (camera network) can lead to have one edge perfectly observed by many cameras and other edges lacking. In this case, all three cameras are observing the edge
(the line between
and
) with cost values at zero since
is opposite to their bisector vectors (
,
and
), whereas the two other edges (
and
) are not observed at all since their cost value can not be zero. The second part of Algorithm 4 is dedicated to eliminating this problem using the penalty function in Equation (
2).
Figure 5.
The local minima problem for a triangular polygon and three cameras. Using just the cost value for each gene (camera) regardless of the other genes (cameras) in the same chromosome (camera network) can lead to have one edge perfectly observed by many cameras and other edges lacking. In this case, all three cameras are observing the edge
(the line between
and
) with cost values at zero since
is opposite to their bisector vectors (
,
and
), whereas the two other edges (
and
) are not observed at all since their cost value can not be zero. The second part of Algorithm 4 is dedicated to eliminating this problem using the penalty function in Equation (
2).
ALGORITHM 5: Genetic algorithm to search for an optimal solution for camera placement problem. |
![Jsan 04 00293 i005]() |
Figure 6.
Extension of the proposed algorithm to search for an optimal camera placement from 2D to 3D. In the case of 3D, instead of considering the normals of the edges of the polygon, the normal vectors of the faces must be considered. Moreover, the position part of each gene () must be considered as a 3D vector. The rest of the algorithm would be the same as the 2D case.
Figure 6.
Extension of the proposed algorithm to search for an optimal camera placement from 2D to 3D. In the case of 3D, instead of considering the normals of the edges of the polygon, the normal vectors of the faces must be considered. Moreover, the position part of each gene () must be considered as a 3D vector. The rest of the algorithm would be the same as the 2D case.