# Identification of Location and Camera Parameters for Public Live Streaming Web Cameras
## 4 Formulation of the Problem and Its Solution Algorithm  
Designers and users of transport models are interested in the flow density (number of vehicles per unit of lane length or direction at a time); speed of vehicles (on a lane or direction); and intensity of the flow (number of vehicles crossing the cross section of a lane or direction). We capture some areas (ROI) of the frames to determine these values from a fixed camera. The camera generates a series of ROI images, usually at a fixed interval, such as 25 frames/second. The algorithms (object detection or instance segmentation or contours detection and object tracking, see [14; 15; 16; 17]) find a set of contours describing the trajectory of each vehicle crossing the ROI. The contour description consists of the coordinates of the vertices in \(F_{im}\). We count the number of contours per meter in the ROI of each frame to estimate flow density. We choose the vertex (e.g., \"bottom left\") of the contour in the trajectory and count the meters that the vertex has passed in the trajectory to estimate the car speed. Both cases require estimation in meters of distance given in pixels, so we need to convert lengths in the image (in \(F_{im}\)) to lengths in space (in \(F_{em}\) or \(F_{c}\)). In some examples, distances in pixels are related to metric distances almost linearly (where radial and perspective distortions are negligible). We will consider the public cameras that produce images with significant radial and perspective distortions in the ROI (more common case).  
**Problem 1**.:
1. _Let_ \(Q\) _be the area that is a plane section of the road surface in space (the road plane can be inclined);_
2. \(\Phi\) _is the camera frame of_ \(N\times M\) _resolution containing the image of_ \(Q\)_, denoting the image by_ \(Q_{im}\)_;_
3. _The camera forms pixel coordinates of the image_ \(\Phi\) _according to the model (_3_), (_7_)-(_9_) with unknown parameters_ \(f_{u},f_{v},k_{1},k_{2},R\)_,_ \[Q_{im}=\Lambda(Q_{em});\]
4. \(\Phi\) _contains the image of at least one segment, the prototype of which in space is a segment of a straight line with a known slope (e.g., vertical);_
5. _The image is centered relative to the optical axis of the video camera, that is,_ \(c_{u}=N/2\) _and_ \(c_{v}=M/2\)_;_
6. _The_ \(F_{em}\) _coordinates of the points_ \(O\) _(camera position) and_ \(G\) _(the source of the optical center_ \(C\)_) are known;_
7. _The_ \(F_{im}\) _coordinates of one or more pixels of_ \(\{P^{u}_{im}\
eq C\}\) _located on the line_ \(v=c_{v}\) _and the_ \(F_{em}\) _coordinates of their sources_ \(\{P^{u}_{em}\}\) _are known;_
8. _The_ \(F_{im}\) _coordinates of one or more pixels of_ \(\{P^{v}_{im}\
eq C\}\) _located on the line_ \(u=c_{u}\) _and the_ \(F_{em}\) _coordinates of their sources_ \(\{P^{v}_{em}\}\) _are known;_
9. _The_ \(F_{em}\) _coordinates of three or more points_ \(\{P^{Q}_{em}\}\in Q\) _are known; at least three of them must be non-collinear;_
10. _The_ \(F_{im}\) _coordinates of one or more groups of three pixels_ \(\{(P^{a}_{im^{\prime}},P^{b}_{im},P^{c}_{im})\}\) _are known, and in the group, the sources of the pixels are collinear in space._ _Find the parameters of the camera_ \(f_{u},f_{v},R,k_{1}\)_, and_ \(k_{2}\) _and construct the mapping_ \[Q_{em}=\Lambda^{-1}(Q_{im}).\]  
Online maps allow remote estimation of global coordinates of points and horizontal distances. Many such maps do not show the altitude, and most do not show the height of buildings, bridges, or vegetation. Online photographs, street view images, and horizontal distances can help estimate such objects' heights. Camera locations are often visible in street photos. This variant of measurements suggests that the coordinate estimates may contain a significant error. The errors result in some algorithms (e.g., PnPransac) being able to generate a response with an unacceptable error.  
To find \(\{P^{u}_{im}\}\),\(\{P^{u}_{em}\}\),\(\{P^{v}_{im}\}\), and \(\{P^{v}_{em}\}\) coordinates, the points must be visible both in the image and on the online map.