Invention content
The purpose of the present invention is to provide a kind of camera status control methods, it is intended to which solving existing camera tracer technique cannot
The problem of carrying out logic control and the triggering switching of complex scene switching.
In order to solve the above-mentioned technical problem, the invention is realized in this way:A kind of method of camera status control, the side
Method includes the following steps:
Obtain the coloured image of preset format in the picture of camera shooting;
Gray scale pretreatment is carried out to the coloured image;
Judge whether the state of the camera meets state according to the coloured image of preset algorithm and the carry out gray scale pretreatment
Handover triggering condition;
If it is satisfied, then sending status switching instruction corresponding with the state, state switching is carried out to control the camera.
Preferably, this includes to the step of coloured image progress gray scale pretreatment:
The coloured image is converted into single channel gray level image;
By normalization algorithm by the single channel greyscale image transitions be normal grayscale image;
Mean filter smoothing processing is carried out to the normal grayscale image, to obtain smooth grey image.
Preferably, the coloured image according to preset algorithm and the carry out gray scale pretreatment judge the camera state whether
The step of meeting state handover triggering condition include:
The state set of the camera is initialized, which includes the operating status and panoramic scene state of the camera;
Obtain the smooth grey image;
Control the camera enter with the smooth grey image corresponding states, and according to default scene switching trigger algorithm judge
Whether the smooth grey image corresponding states is motion state;
If it is, executing the corresponding with the motion state first default triggering judges algorithm;
If it is not, then executing the corresponding with the smooth grey image corresponding states second default triggering judges algorithm.
Preferably, it is also wrapped after the step of execution the first default triggering corresponding with the motion state judges algorithm
It includes:
Judge whether the camera is static;
If it is, when the motion state variable of the camera is set as static the corresponding state variable of scene and return with
Obtain the smooth grey image;
The smooth grey image is obtained if it is not, then directly returning.
Preferably, the step of algorithm is judged in the execution the second default triggering corresponding with the smooth grey image corresponding states
Further include after rapid:
Judge whether the smooth grey image corresponding states meets state handover triggering condition;
If it is, setting the smooth grey image corresponding states variable to interim scene corresponding states variable and returning
Obtain the smooth grey image.
The smooth grey image is obtained if it is not, then returning.
Preferably, the default scene switching triggering algorithm of the basis judges whether the smooth grey image corresponding states is movement
The step of state includes:
The sport foreground binary map B of current smooth grey-level image frame is calculated according to following formulat;
The foreground area accounting Ar of area-of-interest is calculated according to following formula;
Meet the lasting frame number count of foreground area accounting Ar according to following formula statistics;
Judge that this continues whether frame number is more than default triggering frame number threshold value;
Wherein, Gt-2,Gt-1,GtIndicate that the smooth grey image of t-2 frames, t-1 frames, t frames, t are positive integer respectively,
X, y indicate that the position of image pixel column and row, T indicate the threshold value of binaryzation respectively, and Tr ∈ [0.1,1], x, y, w, h are indicated respectively
The abscissa of the top left corner apex of region in the picture, ordinate, the width in region and the height in region, i, j indicate region respectively
The high start of wide starting point and region.
The present invention also aims to provide a kind of device of camera status control, which includes:
Acquiring unit, the coloured image for obtaining preset format in the picture that camera is shot;
Pretreatment unit, for carrying out gray scale pretreatment to the coloured image;
Judging unit, the state for judging the camera according to the coloured image of preset algorithm and the carry out gray scale pretreatment
Whether state handover triggering condition is met;
Transmission unit, for when the state of the camera meets state handover triggering condition, sending corresponding with the state
Status switching instruction carries out state switching to control the camera.
Preferably, which includes:
First conversion subunit, for the coloured image to be converted to single channel gray level image;
Second conversion subunit is standard grayscale figure for passing through normalization algorithm by the single channel greyscale image transitions
Picture;
Smoothing processing subelement, for carrying out mean filter smoothing processing to the normal grayscale image, to obtain smooth ash
Spend image.
Preferably, which includes:
Subelement is initialized, the state set for initializing the camera, which includes the operation shape of the camera
State and panoramic scene state;
Subelement is obtained, for obtaining the smooth grey image;
Subelement is controlled, is entered and the smooth grey image corresponding states for controlling the camera;
First judgment sub-unit judges the smooth grey image corresponding states for triggering algorithm according to default scene switching
Whether it is motion state;
First executes subelement, for when the smooth grey image corresponding states is motion state, executing and the movement
The corresponding first default triggering of state judges algorithm;
Second executes subelement, flat with this for when the smooth grey image corresponding states is not motion state, executing
Sliding gray level image corresponding states corresponding second presets triggering and judges algorithm.
Preferably, which further includes:
Second judgment sub-unit, for judging whether the camera is static;
First setting subelement, is used for when the camera is static, when the motion state variable of the camera is set as static
The corresponding state variable of scene and return obtain the smooth grey image;
Second setting subelement, for when the camera is not static, returning and obtaining the smooth grey image.
Preferably, which further includes:
Third judgment sub-unit, for judging whether the smooth grey image corresponding states meets state handover trigger item
Part;
Subelement is arranged in third, for when the smooth grey image corresponding states meets state handover triggering condition,
It sets the smooth grey image corresponding states variable to interim scene corresponding states variable and returns described smooth to obtain
Gray level image.
The smooth grey image is obtained if it is not, then directly returning.
Preferably, which is specifically used for:
The sport foreground binary map B of current smooth grey-level image frame is calculated according to following formulat;
The foreground area accounting Ar of area-of-interest is calculated according to following formula;
Meet the lasting frame number count of foreground area accounting Ar according to following formula statistics;
Judge that this continues whether frame number is more than default triggering frame number threshold value;
Wherein, Gt-2,Gt-1,GtIndicate that the smooth grey image of t-2 frames, t-1 frames, t frames, t are positive integer respectively,
X, y indicate that the position of image pixel column and row, T indicate the threshold value of binaryzation respectively, and Tr ∈ [0.1,1], x, y, w, h are indicated respectively
The abscissa of the top left corner apex of region in the picture, ordinate, the width in region and the height in region, i, j indicate region respectively
The high start of wide starting point and region.
In the embodiment of the present invention, the coloured image of preset format and to the colour in the picture by obtaining camera shooting
Image carries out gray scale pretreatment and obtains the current state of camera, according to preset algorithm and the cromogram for carrying out gray scale pretreatment
As judging whether the state of the camera meets state handover triggering condition, the state of camera is cut according to judging result
It changes.Method and apparatus provided in an embodiment of the present invention can efficiently carry out logic control and the state switching of complex scene switching
Control.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation describes, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
Fig. 1 shows the flow of camera status control method provided in an embodiment of the present invention, specifically includes following steps:
Step S101 obtains the coloured image of preset format in the picture of camera shooting.
In embodiments of the present invention, which carrys out phase for teacher's tracking in teaching writing/playing system, cromogram image source
The picture of machine shooting, obtains the coloured image I of the i-th frame YUVY formats (preset format) from the picture that camera is shoti, wherein scheming
Image width height is respectively R ', C '.
Step S102 carries out gray scale pretreatment to the coloured image.
As shown in Fig. 2, step S102's specifically includes following steps:
Step S201, by coloured image IiBe converted to single channel gray level image G 'i;
Step S202, by normalization algorithm by single channel gray level image G 'iBe converted to (wide R and high C) standard grayscale
Image G "i.In this embodiment, it is preferred that R=352 and C=288.
Step S203, to normal grayscale image G "i(a × a) mean filter smoothing processing is carried out, to obtain smooth grey
Image Gi.In the present embodiment, preferably a=3 (a is positive integer).
Step S103 judges whether the state of the camera is full according to preset algorithm and the coloured image for carrying out gray scale pretreatment
Sufficient state handover triggering condition.
If so, thening follow the steps S104;If it is not, then cycle executes step S103.
In embodiments of the present invention, in recorded broadcast of imparting knowledge to students, the state of camera have it is multiple, such as camera movement shape
State, the pan-shot state of camera, the feature shooting state of camera, and feature shooting can have multiple scenes, pass through progress
The coloured image of gray scale pretreatment judges the state of camera, and judges whether the state meets state switching by preset algorithm
Trigger condition, when teacher walks about under some scene, if not triggering the condition of scene switching, camera will be located always
In the scene, without being switched in other scenes, if meet state handover triggering condition, such as teacher walks from scene
Go out, then can be switched to suitable scene to record the teaching process of teacher, the movement of camera is will produce during scene switching, is sentenced
Whether disconnected camera stops contributing to the analysis of image.
As shown in figure 3, as a preferred embodiment of the present invention, step S103 specifically includes following steps:
Step S301 initializes the state set of camera, which includes the operating status and panoramic scene of camera
State.
In embodiments of the present invention, the state set of camera is denoted as S, S={ s0,s1,…,sK, which includes
Camera motion state (is denoted as s0, camera motion state can have it is multiple, in this example, it is assumed that only there are one camera motion
State), camera panoramic scene state (is denoted as s1, panorama state can have it is multiple, in this example, it is assumed that only there are one complete
The scene of scape shooting), camera feature scene state (is denoted as s2,…,sK).Scene state s1,…,sKCamera has been corresponded to respectively
Posture p1,…,pK, wherein pi={ pani,tilti,zoomi, i=1,2 ..., K, wherein pani,tilti,zoomiIt indicates respectively
Scene state siThe feathering angle of lower camera, camera and horizontal line inclination angle, the scaling multiplying power of camera.Because of the height of camera installation
Degree is fixed, therefore three parameters are that can determine the posture of camera.Due to needing to judge camera when starting teachers ' teaching recorded broadcast algorithm
Whether stop settling out, it is therefore assumed that the state of the initialization of camera is motion state, has remembered that the state s of camera is movement
State s0.The temporary variable st=s of scene state1, i.e., after camera motion stopping to stable state, panorama triggering field will be switched to
Scape s1。
Step S302, (from step S102) obtain smooth grey image Gi。
Step S303, control camera enter and smooth grey image GiCorresponding state S, and according to default scene switching
Triggering algorithm judges whether smooth grey image corresponding states S is motion state S0。
If so, thening follow the steps S304;If not, thening follow the steps S305.
Step S304, (when smooth grey image corresponding states S is motion state S0When, it is unsatisfactory for state handover trigger
Condition) it executes and motion state S0Corresponding first default triggering judges algorithm, and executes step S306;
Step S305, (when smooth grey image corresponding states S is not motion state S0When, meet state handover trigger
Condition) it executes and smooth grey image GiThe corresponding second default triggerings of corresponding states S judge algorithm, and execute step
S308。
Step S306 judges whether camera is static.
If so, thening follow the steps S307;If not, thening follow the steps S302.
Step S307, the corresponding state variable of scene (state S settings when the motion state variable of camera is set as static
For state st), and return to step S302.
In embodiments of the present invention, step S307 indicates that camera is stable, successful switch to state st。
Step S308, judges whether smooth grey image corresponding states S meets state handover triggering condition;
If so, S309 is thened follow the steps, if not, thening follow the steps S302.
Step S309 sets the smooth grey image corresponding states S variables to interim scene corresponding states variable (state
S is set as S0), and return to step S302.
In the present embodiment, the triggering preset algorithm of camera motion state uses two kinds of strategies, the first is the set time
Determination strategy, be fixed since algorithm obtains image, such as with 25fps, then algorithm can be executed every 40 milliseconds it is primary,
As long as algorithm executed in 40 milliseconds completion so ensure that real-time, if therefore assume image obtain frame per second be m fps,
Setting meets trigger condition after maxT second, then meets trigger condition after algorithm performs maxT × m times, i.e. execution step S307.
Second is the determination strategy for inquiring camera posture, due to the value of Pan, Tilt and the Zoom of known switching, therefore
CP, cT and cZ value that can be current by constantly inquiring camera, then compares the value of Pan, Tilt and Zoom, that is, is required to meet item
Part:
|Pan-cP|<Tp and | Tilt-cT |<Tt and | Zoom-cZ |<Tz
Wherein, cP indicates the current level angle of camera, and unit is identical as Pan, and cT indicates the current vertical pivoting angle of camera,
Unit is identical as Tilt, and cZ indicates the current focal length of camera, and unit is identical as Zoom, and Tp ∈ [0,360), Tt ∈ [0,90], Tz
∈[0,10].Preferred Tp=0.1 in this example, Tt=0.1, Tz=0.01.If formula condition in satisfaction, thens follow the steps
S307。
The triggering algorithm of panoramic scene state.In the present embodiment, a kind of simply and effectively triggering algorithm of design, it is interested
The region of image is (x, y, w, h), and x, y, w, h indicate the abscissa of the top left corner apex of region in the picture respectively, ordinate,
The width in region and the height in region, area-of-interest may be other irregular regions, and the area-of-interest in this example is
Rectangle.The difference of area-of-interest, it is meant that if detecting the condition for meeting triggering, phase in the area-of-interest
Machine will switch to the scene of other features from panoramic scene.
As shown in figure 4, as a preferred embodiment of the present invention, step S303 includes the following steps:
Step S401 calculates the sport foreground binary map of current smooth grey-level image frame.It is calculated according to following formula current
The sport foreground binary map B of smooth grey image framet:
In the present embodiment, the sport foreground of current smooth grey-level image frame is obtained, it is assumed that execute to t frames, obtain ash
Spend image Gt-2,Gt-1,Gt, wherein x, y indicate that the pixel column of smooth grey image, capable position, T indicate the threshold value of binaryzation.
Step S402 calculates the foreground area accounting of area-of-interest.Before area-of-interest being calculated according to following formula
Scape area accounting Ar:
In the present embodiment, it by formula it is found that Ar illustrates the accounting (scope of activities) in specified area-of-interest, takes
It is worth range between 0 to 1, value is bigger to illustrate that scope of activities is bigger, on the contrary then smaller.
In addition, in the present embodiment, the region of image of interest is (x, y, w, h), and x, y, w, h indicate that region is being schemed respectively
As in top left corner apex abscissa, ordinate, region width and region height, i, j indicate respectively region wide starting point and
The high start in region, area-of-interest may be other irregular regions, and the area-of-interest in this example is rectangle.Sense
The difference in interest region, it is meant that if detecting the condition for meeting triggering in the area-of-interest, camera will be from
Panoramic scene switches to the scene of other features.
Step S403, statistics meet the lasting frame number of foreground area accounting Ar.Meet foreground facets according to following formula statistics
The lasting frame number count of product accounting Ar:
In the present embodiment, Tr is the threshold value of mobility, and value range is between 0.1 to 1, we are preferred in this example
0.4, the scope of activities for accurately judging the target in given region can be reached, panorama triggering is the most reasonable.max(v1,
V2) function representation obtains the maximum value in in-real v1, v2.
Step S404 judges that this continues whether frame number count is more than default triggering frame number threshold value Tc.
In the present embodiment, be preferably Tc=10 in this example if count is more than the threshold value Tc of a certain positive integer, then it is full
Sufficient state handover triggering condition.
It should be noted that in embodiments of the present invention, the target in feature scene is larger, moving target can be carried out with
Track, and the track moved according to target, whether analysis meets the condition of triggering under the feature scene, in the feelings that video camera is static
Under condition, more ripe triggering algorithm, such as w4 track algorithms (W4 can be used:Real-Time Surveillance of
People and Their Activities, Ismail Haritaoglu, David Harwood, Larry S.Davis) etc..
Step S104 sends status switching instruction corresponding with the state, and state switching is carried out to control camera.
In embodiments of the present invention, step S309 is completed to need to send new phase it means that scene will switch
Machine control instruction, the movement speed { vpan of video cameraj,vtiltjAnd new posture pj={ panj,titlj,zoomjSo that
Camera motion is to new scene.Assuming that the camera posture of a upper scene is po={ pano,tilto,zoomo, what current queries arrived
Camera posture is pc={ panc,tiltc,zoomc, then the speed calculation formula of Current camera movement is as follows:
Wherein α, β indicate to rotate horizontally the decay factor of the decay factor and vertical rotary speed of speed, sgn (x) respectively
For sign function, even x >=0, sgn (x)=1, otherwise sgn (x)=- 1.It is preferably α=2, β=1 in this example.
After camera motion speed is calculated according to above formula, the instruction for being sent to camera is { vpanj,vtiltj,
panj,tiltj,zoomj, after camera receives parameter, smooth movement will be carried out according to given speed, solve picture not
Smooth problem.
In embodiments of the present invention, by the coloured image of preset format in the picture of acquisition camera shooting and to the coloured silk
Color image carries out gray scale pretreatment and obtains the current state of camera, according to preset algorithm and the colour for carrying out gray scale pretreatment
Image judges whether the state of the camera meets state handover triggering condition, is cut to the state of camera according to judging result
It changes.Method and apparatus provided in an embodiment of the present invention can efficiently carry out logic control and the state switching of complex scene switching
Control.
The purpose of the embodiment of the present invention also resides in the device 1 for providing a kind of control of camera status, including acquiring unit 10, pre-
Processing unit 20, judging unit 30 and transmission unit 40.
In embodiments of the present invention, acquiring unit 10 is used to obtain the cromogram of preset format in the picture that camera is shot
Picture;Pretreatment unit 20 is used to carry out gray scale pretreatment to the coloured image;Judging unit 30 is used for according to preset algorithm and is somebody's turn to do
The coloured image for carrying out gray scale pretreatment judges whether the state of camera meets state handover triggering condition;Transmission unit 40 is used for
When the state of camera meets state handover triggering condition, status switching instruction corresponding with the state is sent, to control camera
Carry out state switching.
As a preferred embodiment of the present invention, pretreatment unit 20 includes that the first conversion subunit 201, second conversion is single
Member 202, smoothing processing subelement 203.
In embodiments of the present invention, the first conversion subunit 201 is used to the coloured image being converted to single channel gray-scale map
Picture;Second conversion subunit 202 is used to through normalization algorithm be normal grayscale image by the single channel greyscale image transitions;It is flat
Sliding processing subelement 203 is used to carry out mean filter smoothing processing to the normal grayscale image, to obtain smooth grey image.
As a preferred embodiment of the present invention, judging unit 30 includes initialization subelement 301, obtains subelement 302, control
Subunit 303, the first judgment sub-unit 304, first execute subelement 305, second and execute judgement of subelement 306, second
Unit 307, first is arranged subelement 308, second and subelement 309, third judgment sub-unit 310 and third setting son list is arranged
Member 311.
In embodiments of the present invention, initialization subelement 301 is used to initialize the state set of camera, the state set packet
Include the operating status and panoramic scene state of camera;Subelement 302 is obtained for obtaining the smooth grey image;Control subelement
303 enter and the smooth grey image corresponding states for controlling camera;First judgment sub-unit 304 is used for according to default scene
Handover trigger algorithm judges whether the smooth grey image corresponding states is motion state;First, which executes subelement 305, is used for
When the smooth grey image corresponding states is motion state, executes the corresponding with the motion state first default triggering and judge to calculate
Method;Second, which executes subelement 306, is used for when the smooth grey image corresponding states is not motion state, executes and the smooth ash
The corresponding second default triggering of degree image corresponding states judges algorithm;Second judgment sub-unit 307 is for judging whether camera is quiet
Only;First setting subelement 308 is used for when camera is static, and scene corresponds to when the motion state variable of camera is set as static
State variable and return obtain the smooth grey image;Second setting subelement 309 is used for when camera is not static, is returned
Obtain the smooth grey image;Third judgment sub-unit 310 is for judging whether the smooth grey image corresponding states meets shape
State handover triggering condition;Third setting subelement 311 is used to meet state handover trigger item in smooth grey image corresponding states
When part, sets the smooth grey image corresponding states variable to interim scene corresponding states variable and return smooth to obtain this
Gray level image.
As a preferred embodiment of the present invention, first judgment sub-unit 304 is specifically used for:
The sport foreground binary map B of current smooth grey-level image frame is calculated according to following formulat;
The foreground area accounting Ar of area-of-interest is calculated according to following formula;
Meet the lasting frame number count of foreground area accounting Ar according to following formula statistics;
Judge that this continues whether frame number is more than default triggering frame number threshold value;
Wherein, Gt-2,Gt-1,GtIndicate that the smooth grey image of t-2 frames, t-1 frames, t frames, t are positive integer respectively,
X, y indicate that the position of image pixel column and row, T indicate the threshold value of binaryzation respectively, and Tr ∈ [0.1,1], x, y, w, h are indicated respectively
The abscissa of the top left corner apex of region in the picture, ordinate, the width in region and the height in region, i, j indicate region respectively
The high start of wide starting point and region.
The embodiment phase for the method that camera status control device provided in an embodiment of the present invention is controlled with above-mentioned camera status
Corresponding, operation principle and mode are corresponding applicable, just repeat no more here.
In embodiments of the present invention, by the coloured image of preset format in the picture of acquisition camera shooting and to the coloured silk
Color image carries out gray scale pretreatment and obtains the current state of camera, according to preset algorithm and the colour for carrying out gray scale pretreatment
Image judges whether the state of the camera meets state handover triggering condition, is cut to the state of camera according to judging result
It changes.Method and apparatus provided in an embodiment of the present invention can efficiently carry out logic control and the state switching of complex scene switching
Control.
One of ordinary skill in the art will appreciate that realizing all or part of flow in above-described embodiment method, being can be with
Relevant hardware is instructed to complete by computer program, the program can be stored in computer read/write memory medium
In, the program is when being executed, it may include such as the flow of the embodiment of above-mentioned each method.Wherein, the storage medium can be magnetic
Dish, CD, read-only memory (Read-Only Memory, ROM) or random access memory (Random Access
Memory, RAM) etc..
The above disclosure is only the preferred embodiments of the present invention, cannot limit the right model of the present invention with this certainly
It encloses, therefore equivalent changes made in accordance with the claims of the present invention, is still within the scope of the present invention.