The method and system of automatic switch image unit
Technical field
The invention belongs to electronic information technical field, relate to a kind of image unit control method, relate in particular to a kind of method of automatic switch image unit; Simultaneously, the invention still further relates to a kind of system of automatic switch image unit.
Background technology
Camera becomes the standard configuration of mobile phone gradually now, and increasing mobile phone begins to be equipped with camera, and most of camera all is assemblied in the back side of mobile phone.The pixel count of mobile phone cam is usually all more than 2,000,000, and the CPU of mobile phone is usually more than 200MHz.Accelerometer also begins to be adopted by some middle and high end mobile phones gradually, becomes its standard configuration.Accelerometer can obtain the vector data of the acceleration of motion of mobile phone under three dimensional space coordinate in real time, has certain precision.
Along with camera popularizing on mobile phone, a collection of mobile application based on camera begins to be extensive use of by people, and translating such as the all-round king of the business card of the information of closing and bat all can the king.And wherein have some to use, such as bat translate all can the king be very frequent for the use of camera.People run into new word through regular meeting and need get speech by camera and come query translation, just as holding a magnifying glass according to new word at ordinary times when reading foreign language periodical and document.Common usage behavior is picked up mobile phone exactly, opens camera, aims at new word, and the query translation result closes camera then, puts down mobile phone.This wherein has two steps, opens and closes camera, all needs artificial button click to finish usually.Sometimes the user has inquired about new word and can forget also and close camera and put down mobile phone that at this moment mobile phone is leaving camera and can waste electric weight.
Summary of the invention
Technical problem to be solved by this invention is: the method that a kind of automatic switch image unit is provided, make people when using some based on the application of camera, save the operation of loaded down with trivial details button click, accomplish more convenient switch camera, use more comfortablely, simultaneously also saved user's time.
In addition, the present invention also provides a kind of system of automatic switch image unit, makes people when using some based on the application of camera, save the operation of loaded down with trivial details button click, accomplish more convenient switch camera, use more comfortablely, simultaneously also saved user's time.
For solving the problems of the technologies described above, the present invention adopts following technical scheme:
A kind of method of automatic switch image unit, described method comprises the steps:
Step 101, the user at first starts the application program on the mobile phone, the camera on the automatic starting hand-set of this application program, and the picture image that camera grasps is caught in beginning in real time; Go to step 102;
Step 102, described application program are obtained the first frame image data P
1, simultaneously count value I is initialized as 0; Go to step 103;
Step 103, program is obtained current picture image P at ensuing each time point
t, and with a two field picture P who obtains before
T-1Compare, calculate the luminance difference of two each pixel of width of cloth image, and the luminance difference of all pixels is averaged, try to achieve the average M of luminance difference; Go to step 104;
Step 104 is if M surpasses a threshold value M who configures in advance
T, then count value I is made as 0, otherwise count value I is added 1; Go to step 105;
Step 105 is if count value I surpasses a threshold value I who configures in advance
T, think that then interior camera picture of a period of time is almost static, mobile phone may be in idle state, and application program is closed camera automatically; Go to step 106; Otherwise get back to step 103;
Step 106, after camera was closed, described application program began to obtain the acceleration that accelerometer is fastened at three-dimensional coordinate, and calculated its amplitude G, if G surpasses a threshold value G who configures in advance
T, think that then the user picks up mobile phone, Automatic Program is opened camera; Go to step 107;
Step 107, if user's bolt down procedure, EP (end of program) then, otherwise get back to step 102.
A kind of method of automatic switch image unit, described method comprises the steps:
The application program of step S100, startup electronic equipment, the image unit of the automatic unlocking electronic equipment of this application program, beginning is pounced in real time and is caught the picture image that image unit grasps;
Step S200, every the picture image of the described extracting of setting-up time interval acquiring, and judge according to the picture image that obtains whether electronic equipment is in idle state, if close image unit automatically;
After step S300, image unit were closed, described application program began to obtain the acceleration that accelerometer is fastened at three-dimensional coordinate, and calculated its amplitude G; If G surpasses a threshold value GT who configures in advance, then described application program is opened camera automatically, goes to step 200.
As a preferred embodiment of the present invention, among the said step S200, judge that the method whether electronic equipment is in idle state comprises:
Described application program is obtained the first frame image data P
1, begin counting simultaneously;
Described application program is obtained current picture image P at ensuing each time point
t, and with a two field picture P who obtains before
T-1Compare, calculate the luminance difference of two each pixel of width of cloth image, and the luminance difference of all pixels is averaged, try to achieve the average M of luminance difference;
If M surpasses a threshold value M who configures in advance
T, then restart counting, otherwise count value adds 1;
If count value surpasses a threshold value that configures in advance, think that then electronic equipment may be in idle state.
As a preferred embodiment of the present invention, among the said step S200, judge that the method whether electronic equipment is in idle state comprises:
Step S102, described application program is obtained the first frame image data P
1, simultaneously count value I is initialized as 0; Go to step S103;
Step S103, described application program is obtained current picture image P at ensuing each time point
t, and with a two field picture P who obtains before
T-1Compare, calculate the luminance difference of two each pixel of width of cloth image, and the luminance difference of all pixels is averaged, try to achieve the average M of luminance difference; Go to step S104;
Step S104 is if M surpasses a threshold value M who configures in advance
T, then count value I is made as 0, otherwise count value I is added 1; Go to step S105;
Step S105 if count value I surpasses a threshold value IT who configures in advance, thinks that then interior image unit picture of a period of time is almost static, and electronic equipment may be in idle state, and described application program is closed image unit automatically, goes to step S300; Otherwise get back to step S103.
A kind of system of automatic switch image unit, described system comprises:
Image unit is opened control unit, in order to open image unit;
Image unit closing control unit is in order to close image unit;
The picture placement unit is in order to the picture image every the described extracting of setting-up time interval acquiring;
Idle judging unit, judge in order to the picture image that obtains according to described picture placement unit whether electronic equipment is in idle state, if then send a control signal to described image unit closing control unit, image unit closing control unit is closed image unit automatically;
Enable judging unit, after closing at image unit, obtain the acceleration that accelerometer is fastened at three-dimensional coordinate, and calculate its amplitude G, if G surpasses a threshold value GT who configures in advance, then enable judging unit and send a control signal to described image unit unlatching control unit, image unit is opened control unit and is opened camera automatically.
As a preferred embodiment of the present invention, the method whether described idle judgment unit judges electronic equipment is in idle state comprises:
Described application program is obtained the first frame image data P
1, begin counting simultaneously;
Described application program is obtained current picture image P at ensuing each time point
t, and with a two field picture P who obtains before
T-1Compare, calculate the luminance difference of two each pixel of width of cloth image, and the luminance difference of all pixels is averaged, try to achieve the average M of luminance difference;
If M surpasses a threshold value M who configures in advance
T, then restart counting, otherwise count value adds 1;
If count value surpasses a threshold value that configures in advance, think that then electronic equipment may be in idle state.
As a preferred embodiment of the present invention, the method whether described idle judgment unit judges electronic equipment is in idle state comprises:
Step S102, described application program is obtained the first frame image data P
1, simultaneously count value I is initialized as 0; Go to step S103;
Step S103, described application program is obtained current picture image P at ensuing each time point
t, and with a two field picture P who obtains before
T-1Compare, calculate the luminance difference of two each pixel of width of cloth image, and the luminance difference of all pixels is averaged, try to achieve the average M of luminance difference; Go to step S104;
Step S104 is if M surpasses a threshold value M who configures in advance
T, then count value I is made as 0, otherwise count value I is added 1; Go to step S105;
Step S105 is if count value I surpasses a threshold value I who configures in advance
T, think that then interior image unit picture of a period of time is almost static, electronic equipment may be in idle state, and described application program is closed image unit automatically, goes to step S300; Otherwise get back to step S103.
For realizing the inventive method, need one and have CPU, internal memory, the mobile phone of camera and accelerometer.Can move the program that writes on this mobile phone, this program can be opened camera, can obtain the picture image that camera is caught real-time dynamicly, can obtain the data of mobile phone accelerometer in real time.
Beneficial effect of the present invention is: the method and system of the automatic switch image unit that the present invention proposes, image matching technology and accelerometer technology are combined, realized the method for automatic switch camera, can allow the user when using this class based on the mobile application of camera, sensation is convenient as snug as a bug in a rug, and save time of user's manual operation switch camera, and simultaneously also can be for the user closes camera when closing camera automatically forgetting, thus the mobile phone electric weight saved.
Description of drawings
Fig. 1 is the flow chart of the method for automatic switch image unit of the present invention.
Embodiment
Describe the preferred embodiments of the present invention in detail below in conjunction with accompanying drawing.
Embodiment one
See also Fig. 1, the present invention has disclosed a kind of method based on the camera on image and the accelerometer automatic switch mobile device, allow people when using some to use based on the mobile phone of camera, save the operation of loaded down with trivial details button click, accomplish more convenient switch camera, use more comfortablely, simultaneously also saved user's time.
As shown in Figure 1, the method for automatic switch image unit of the present invention comprises the steps:
[step 101] user at first starts the application program on the mobile phone, and this program is the camera on the starting hand-set automatically, and the picture image that camera grasps is caught in beginning in real time.
[step 102] program is obtained the first frame image data P
1, simultaneously count value I is initialized as 0.
[step 103] program is obtained current picture image P at ensuing each time point
t, and with the 1 two field picture P that obtains before
T-1Compare, calculate the luminance difference of two each pixel of width of cloth image, and the luminance difference of all pixels is averaged, try to achieve the average M of luminance difference.
[step 104] is if M surpasses a threshold value M who configures in advance
T, then count value I is made as 0, otherwise count value I is added one.
[step 105] is if count value I surpasses a threshold value I who configures in advance
T, think that then interior camera picture of a period of time is almost static, mobile phone may be in idle state, and Automatic Program is closed camera.Otherwise get back to step 103.
After [step 106] camera was closed, program began to obtain the acceleration that accelerometer is fastened at three-dimensional coordinate, and calculated its amplitude G, if G surpasses a threshold value G who configures in advance
T, think that then the user picks up mobile phone, Automatic Program is opened camera.
[step 107] if user's bolt down procedure, EP (end of program) then, otherwise get back to step 102.
Embodiment two
Present embodiment discloses a kind of method of automatic switch image unit, and described method comprises the steps:
[step S100] starts the application program of electronic equipment, the image unit of the automatic unlocking electronic equipment of this application program, and beginning is pounced in real time and is caught the picture image that image unit grasps;
[step S200] every the picture image of the described extracting of setting-up time interval acquiring, and judges according to the picture image that obtains whether electronic equipment is in idle state, if close image unit automatically;
After [step S300] image unit was closed, described application program began to obtain the acceleration that accelerometer is fastened at three-dimensional coordinate, and calculated its amplitude G; If G surpasses a threshold value GT who configures in advance, then described application program is opened camera automatically, goes to step 200.
Among the said step S200, judge that the method whether electronic equipment is in idle state comprises:
-described application program is obtained the first frame image data P
1, begin counting simultaneously;
-described application program is obtained current picture image P at ensuing each time point
t, and with a two field picture P who obtains before
T-1Compare, calculate the luminance difference of two each pixel of width of cloth image, and the luminance difference of all pixels is averaged, try to achieve the average M of luminance difference;
If-M surpasses a threshold value M who configures in advance
T, then restart counting, otherwise count value adds 1;
If-count value surpasses a threshold value that configures in advance, think that then electronic equipment may be in idle state.
Particularly, judge that the method whether electronic equipment is in idle state comprises:
-step S102, described application program is obtained the first frame image data P
1, simultaneously count value I is initialized as 0; Go to step S103;
-step S103, described application program is obtained current picture image P at ensuing each time point
t, and with a two field picture P who obtains before
T-1Compare, calculate the luminance difference of two each pixel of width of cloth image, and the luminance difference of all pixels is averaged, try to achieve the average M of luminance difference; Go to step S104;
-step S104 is if M surpasses a threshold value M who configures in advance
T, then count value I is made as 0, otherwise count value I is added 1; Go to step S105;
-step S105 if count value I surpasses a threshold value IT who configures in advance, thinks that then interior image unit picture of a period of time is almost static, and electronic equipment may be in idle state, and described application program is closed image unit automatically, goes to step S300; Otherwise get back to step S103.
More than disclosed automatic switch image unit method of the present invention, the present invention also discloses a kind of system of automatic switch image unit when disclosing said method.Described system comprises: image unit is opened control unit, image unit closing control unit, picture placement unit, idle judging unit, is enabled judging unit.
Described image unit is opened control unit in order to open image unit.
Described image unit closing control unit is in order to close image unit.
Described picture placement unit is in order to the picture image every the described extracting of setting-up time interval acquiring.
Described idle judging unit judges in order to the picture image that obtains according to described picture placement unit whether electronic equipment is in idle state, if then send a control signal to described image unit closing control unit, image unit closing control unit is closed image unit automatically.
The described judging unit of enabling is in order to after closing at image unit, obtain the acceleration that accelerometer is fastened at three-dimensional coordinate, and calculate its amplitude G, if G surpasses a threshold value GT who configures in advance, then enable judging unit and send a control signal to described image unit unlatching control unit, image unit is opened control unit and is opened camera automatically.
The method whether described idle judgment unit judges electronic equipment is in idle state comprises:
-described application program is obtained the first frame image data P
1, begin counting simultaneously;
-described application program is obtained current picture image P at ensuing each time point
t, and with a two field picture P who obtains before
T-1Compare, calculate the luminance difference of two each pixel of width of cloth image, and the luminance difference of all pixels is averaged, try to achieve the average M of luminance difference;
If-M surpasses a threshold value M who configures in advance
T, then restart counting, otherwise count value adds 1;
If-count value surpasses a threshold value that configures in advance, think that then electronic equipment may be in idle state.
In the present embodiment, the method whether described idle judgment unit judges electronic equipment is in idle state comprises:
-step S102, described application program is obtained the first frame image data P
1, simultaneously count value I is initialized as 0; Go to step S103;
-step S103, described application program is obtained current picture image P at ensuing each time point
t, and with a two field picture P who obtains before
T-1Compare, calculate the luminance difference of two each pixel of width of cloth image, and the luminance difference of all pixels is averaged, try to achieve the average M of luminance difference; Go to step S104;
-step S104 is if M surpasses a threshold value M who configures in advance
T, then count value I is made as 0, otherwise count value I is added 1; Go to step S105;
-step S105 is if count value I surpasses a threshold value I who configures in advance
T, think that then interior image unit picture of a period of time is almost static, electronic equipment may be in idle state, and described application program is closed image unit automatically, goes to step S300; Otherwise get back to step S103.
In sum, the method and system of the automatic switch image unit that the present invention proposes, image matching technology and accelerometer technology are combined, realized the method for automatic switch camera, can allow the user when using this class based on mobile applications of camera, sensation is convenient as snug as a bug in a rug, and the time of saving user manual operation switch camera, simultaneously also can be for the user close camera when closing camera automatically forgetting, thus the mobile phone electric weight saved.
Here description of the invention and application is illustrative, is not to want with scope restriction of the present invention in the above-described embodiments.Here the distortion of disclosed embodiment and change are possible, and the various parts of the replacement of embodiment and equivalence are known for those those of ordinary skill in the art.Those skilled in the art are noted that under the situation that does not break away from spirit of the present invention or substantive characteristics, and the present invention can be with other form, structure, layout, ratio, and realize with other assembly, material and parts.Under the situation that does not break away from the scope of the invention and spirit, can carry out other distortion and change here to disclosed embodiment.