Summary of the invention
In order to improve the utilization factor of processor, the extensibility of enhanced system, the embodiment of the invention provide a kind of method and apparatus of handling image.Described technical scheme is as follows:
On the one hand, the embodiment of the invention provides a kind of method of handling image, and described method comprises:
Obtain with respect to same image at M the image that different angles produced, described M is more than or equal to 2;
When the number of processors that participates in parallel processing is N, be N split image with each image segmentation in the described M image, obtain M*N split image, described N is more than or equal to 2;
M split image according to mutual correspondence is one group, and a described M*N split image is combined as N combination image, distributes to N processor respectively and carries out the parallax computing, obtains N part stereoscopic parallax image;
According to the corresponding relation of a described N split image, with described N part stereoscopic parallax image merge into a stereoscopic parallax image and output.
On the other hand, the embodiment of the invention provides a kind of device of handling image, and described device comprises:
Acquisition module is used to obtain with respect to same image at M the image that different angles produced, and described M is more than or equal to 2;
Cutting apart module, be used for after described acquisition module obtains M image, when the number of processors that participates in parallel processing is N, is N split image with each image segmentation in the described M image, obtains M*N split image, and N is more than or equal to 2;
Distribution module, be used for described cut apart module and obtain M*N split image after, be one group according to M split image of mutual correspondence, a described M*N split image is combined as N combination image, distribute to N processor respectively and carry out the parallax computing, obtain N part stereoscopic parallax image;
Merge module, be used for after described distribution module obtains N part stereoscopic parallax image, according to the corresponding relation of a described N split image, described N part stereoscopic parallax image merged into a stereoscopic parallax image also exports.
The beneficial effect of the technical scheme that the embodiment of the invention provides is:
By the image segmentation that will obtain is a plurality of, and distributes to a plurality of processor processing, reduced processor idle periods, improved a plurality of processors utilization rate, saved operation time, really brought into play the advantage of concurrent operation, real-time is very strong; And, when increasing image source or increasing processor, only do simple modification and can finish the dilatation function, thereby reduced the complexity of system design, the extensibility that has improved system has reduced system cost.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, embodiment of the present invention is described further in detail below in conjunction with accompanying drawing.
Embodiment 1
The embodiment of the invention provides a kind of method of handling image, referring to Fig. 2, comprising:
201: obtain M image, this M is more than or equal to 2;
202: when the number of processors that participates in parallel processing is N, be N split image with each image segmentation in M the image, obtain M*N split image, N is more than or equal to 2;
203: M split image according to mutual correspondence is one group, and M*N split image is combined as N combination image, distributes to N processor respectively and carries out the parallax computing, obtains N part stereoscopic parallax image;
204: according to N the relation that split image is corresponding, with N part stereoscopic parallax image merge into a stereoscopic parallax image and output.
Further, obtaining after M the image, when the number of processors that participates in parallel processing is N, is before N the split image with each image segmentation in M the image, also comprises:
M image carried out pre-service.
Wherein, each pretreatment image in M the image is divided into N split image, can for:
Each image in M the image is remained unchanged in the horizontal direction, each image on average is divided into N split image in vertical direction.
Wherein, each pretreatment image in M the image is divided into N split image, can for:
Each image in M the image is remained unchanged in the horizontal direction, each image is divided into N split image in vertical direction according to default ratio.
Wherein, with N part stereoscopic parallax image merge into a stereoscopic parallax image and output, can for:
N part stereoscopic parallax image merged into a stereoscopic parallax image and output in vertical direction.
Further, above-mentioned when each image segmentation in M the image is N split image, it is overlapping that the image boundary of N split image is carried out the image redundancy.
Further, above-mentioned when N part stereoscopic parallax image merged into a stereoscopic parallax image, it is overlapping that the image boundary of N part stereoscopic parallax image is removed the image redundancy.
Method shown in the present embodiment, by the image segmentation that will obtain is a plurality of, and distributes to a plurality of processor processing, reduced processor idle periods, improved a plurality of processors utilization rate, saved operation time, really brought into play the advantage of concurrent operation, real-time is very strong; And, when increasing image source or increasing processor, only do simple modification and all can finish the dilatation function, thereby reduced the complexity of system design, the extensibility that has improved system reduces system cost.
Embodiment 2
The embodiment of the invention provides a kind of method of handling image, referring to Fig. 3, for comprising two cameras, during two processor, handle the synoptic diagram of image, below to comprise two cameras, two processors are that example is described in detail this method, and referring to Fig. 4, this method comprises:
401: image pretreatment unit 303 receives from the image A 1 of first camera 301 with from the image B 1 of second camera 302, and image A 1 and image B 1 are carried out pre-service, obtains pretreated image A 1 and pretreated image B 1.
Wherein, pre-service is meant corrects or other processing carry out lens distortion from image of camera, and this part is a prior art, repeats no more herein.And need to prove that present embodiment is the image that obtains by camera, can also obtain image by other image acquisition equipment in the practical application.
402: image segmentation unit 304 is divided into 2 parts up and down with pretreated image A 1 and pretreated image B 1, obtains pretreated image A 1 the first half and pretreated image A 1 the latter half, pretreated image B 1 the first half and pretreated image B 1 the latter half.
To pretreated image segmentation can be: according to the number of processors that participates in concurrent operation, pretreated image is remained unchanged in the horizontal direction, pretreated image is cut apart in vertical direction, and specifically be to be and the identical number of number of processors that participates in concurrent operation pretreated image segmentation.The number of processors that participates in concurrent operation in the present embodiment is 2, so pretreated image A 1 and pretreated image B 1 are remained unchanged in the horizontal direction, pretreated image A 1 and pretreated image B 1 are divided into 2 parts in vertical direction, obtain pretreated image A 1 the first half and pretreated image A 1 the latter half, pretreated image B 1 the first half and pretreated image B 1 the latter half.Pretreated image segmentation is not limited to the described number of processors according to the participation concurrent operation of present embodiment, pretreated image is remained unchanged in the horizontal direction, pretreated image is cut apart in vertical direction, can also carry out other and cut apart accordingly, as with pretreated image in the horizontal direction direction cut apart etc.
And, when pretreated image is cut apart, can average pretreated image and cut apart, it is divided into equal several parts; Also can cut apart in default ratio, it is cut apart several parts of corresponding ratio pretreated image.In the present embodiment, pretreated image A 1 and pretreated image B 1 averaged cut apart, pretreated image A 1 and pretreated image B 1 are divided into 2 parts that equate up and down; Can preset ratio be 1: 3 also in addition, be 2 parts of 1: 3 in the default ratio ratio up and down of being divided into pretreated image A 1 and pretreated image B 1.Can be according to the applicable cases of reality, adopt corresponding method to cut apart to pretreated image, for example: the first processor 306 and second processor 307 are for participating in the processor of concurrent operation, and the first processor 306 and second processor 307 are except participating in concurrent operation, do not participate in other work, at this moment pretreated image A 1 and pretreated image B 1 on average can be divided into 2 parts up and down; The first processor 306 and second processor 307 are for participating in the processor of concurrent operation, and first processor 306 is except participating in concurrent operation, also participate in other work, one of the time that first processor 306 can be used for carrying out concurrent operation is three/, at this moment preset ratio is 1: 3, with pretreated image A 1 and pretreated image B 1 ratio up and down of being divided in proportion is 2 parts of 1: 3, and the first half is distributed to first in subsequent process and handle processor 306 and handle.And need to prove, pretreated image is cut apart, be not limited to the method described in the present embodiment.
In addition, consider the needs of follow-up stereoscopic parallax computing when cutting apart, when image is cut apart after to pre-service, it is overlapping to carry out the image redundancy to the image boundary of cutting apart, even adjacent 2 images of cutting apart have parts of images overlapping in vertical direction, for example: the image boundary of cutting apart between pretreated image A 1 the first half and pretreated image A 1 the latter half has parts of images overlapping.
403: with pretreated image A 1 the first half and pretreated image B 1 the first half, be combined as a combination image and distribute to first processor 306, with pretreated image A 1 the latter half and pretreated image B 1 the latter half, be combined as a combination image and distribute to second processor 307.
Need to prove, image A 1 and image B 1 be 2 cameras to same image at two two images that different angles generated, so it is corresponding mutually between the corresponding part between image A 1 and the image B 1, so it is corresponding mutually between pretreated image A 1 the first half and pretreated image B 1 the first half, therefore pretreated image A 1 the first half and pretreated image B 1 the first half are combined as a combination image, in like manner pretreated image A 1 the latter half and pretreated image B 1 the latter half are combined as a combination image.
404: 306 pairs of pretreated image A 1 the first half of first processor and pretreated image B 1 the first half are carried out the stereoscopic parallax computing, obtain stereoscopic parallax image 1 the first half; 307 pairs of pretreated image A 1 the latter halfs of second processor and pretreated image B 1 the latter half are carried out the stereoscopic parallax computing, obtain stereoscopic parallax image 1 the latter half.
405: image merge cells 308 merges stereoscopic parallax image 1 the first half and stereoscopic parallax image 1 the latter half, obtains stereoscopic parallax image 1.
Wherein, merge with step 402 in cut apart corresponding, stereoscopic parallax image 1 the first half is corresponding with pretreated image A 1 the first half and pretreated image B 1 the first half, stereoscopic parallax image 2 the latter halfs are corresponding with pretreated image A 1 the latter half and pretreated image B 1 the latter half, so according to this corresponding relation, with stereoscopic parallax image 1 the first half last and stereoscopic parallax image 1 the latter half under order merge, obtain stereoscopic parallax image 1.And, if when cutting apart, be in cutting apart that vertical direction is carried out, then merge in vertical direction; If it is overlapping to have carried out the image redundancy when cutting apart, when then merging, it is overlapping to remove the image redundancy; If during actual cutting apart, carry out according to other method, to carry out respective handling when then merging.
To receive from the image A 2 of first camera 301 with from the image B 2 of second camera 302, from the image A 3 of first camera 301 with from the image B 3 of second camera 302 ... from the image A n of first camera 301 with from the image B n of second camera 302, handle accordingly respectively according to step 401-step 405 successively, thereby obtain stereoscopic parallax image 2, stereoscopic parallax image 3 ... stereoscopic parallax image n.
Need to prove that the number of image source may be M in the practical application, M is more than or equal to 2, correspondingly, the number that at every turn needs the image of processing is M, and number of processors may be N, N is more than or equal to 2, when image is M, when processor is N, only need every group of M image, handle accordingly, with image segmentation is that N part gets final product, and detailed process such as above-mentioned similar repeats no more herein.And need to prove, when increasing image source, only need revise cut apart, distribute and merge in the picture number of processing, needn't revise logic; Only need revise when increasing processor cut apart, distribute and when merging in the processor number of participation processing, needn't revise logic.
Method shown in the present embodiment, by the image segmentation that will obtain is a plurality of, and distributes to a plurality of processor processing, reduced processor idle periods, improved a plurality of processors utilization rate, saved operation time, really brought into play the advantage of concurrent operation, real-time is very strong; And, when increasing image source or increasing processor, only do simple modification and all can finish the dilatation function, thereby reduced the complexity of system design, the extensibility that has improved system has reduced system cost.
Embodiment 3
Referring to Fig. 5, the embodiment of the invention provides a kind of device of handling image, and this device comprises:
Acquisition module 501 is used to obtain M image, and M is more than or equal to 2;
Cutting apart module 502, be used for after acquisition module 501 obtains M image, when the number of processors that participates in parallel processing is N, is N split image with each image segmentation in M the image, obtains M*N split image, and N is more than or equal to 2;
Distribution module 503, being used for after cutting apart module 502 and obtaining M*N split image, is one group according to M split image of mutual correspondence, and M*N split image is combined as N combination image, distribute to N processor respectively and carry out the parallax computing, obtain N part stereoscopic parallax image;
Merge module 504, be used for after distribution module 503 obtains N part stereoscopic parallax image, according to N the relation that split image is corresponding, N part stereoscopic parallax image merged into a stereoscopic parallax image also exports.
Further, this device also comprises:
Pretreatment module 505 is used for after acquisition module 501 obtains M image M image being carried out pre-service, and a pretreated M image sent to cuts apart module 502 and handle.
Wherein, cut apart module 502, specifically be used for each image of M image is remained unchanged in the horizontal direction, each image on average is divided into N split image in vertical direction.
Wherein, cut apart module 502, specifically be used for each image of M image is remained unchanged in the horizontal direction, each image is divided into N split image in vertical direction according to default ratio.
Wherein, merge module 504, specifically be used for N part stereoscopic parallax image merged into a stereoscopic parallax image and output in vertical direction.
Further,
Cut apart module 502, also be used for when each image segmentation with M image is N split image, it is overlapping that the image boundary of N split image is carried out the image redundancy.
Further,
Merge module 504, also be used for when N part stereoscopic parallax image merged into a stereoscopic parallax image, it is overlapping that the image boundary of N part stereoscopic parallax image is removed the image redundancy.
Device shown in the present embodiment, by the image segmentation that will obtain is a plurality of, and distributes to a plurality of processor processing, reduced processor idle periods, improved a plurality of processors utilization rate, saved operation time, really brought into play the advantage of concurrent operation, real-time is very strong; And, when increasing image source or increasing processor, only do simple modification and all can finish the dilatation function, thus reduced system design complexity, improved system extensibility reduction system cost.
All or part of content in the technical scheme that above embodiment provides can realize that its software program is stored in the storage medium that can read by software programming, storage medium for example: the hard disk in the computing machine, CD or floppy disk.
The above only is preferred embodiment of the present invention, and is in order to restriction the present invention, within the spirit and principles in the present invention not all, any modification of being done, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.