Method for focusing a camera, wherein a plurality of focus regions is defined in the camera view, said method comprising: repeatedly setting a focus distance of the camera to focus at different distances by setting a lens distance of the camera to different lens distance values, determining, in response to setting a lens distance, a focus value for each focus region at the set lens distance value, characterized in estimating, when a plurality of focus value and lens distance value pairs have been determined, a function of at least degree two for each of a plurality of focus regions, wherein the function represents focus values as a function of lens distance values, calculating, for each focus region for which the function has been estimated, a local maximum point of the function, the local maximum point having a lens distance value, grouping focus regions based on the lens distance value of the local maximum point of the focus regions and spatial distances between the focus regions, rating the focus region groups resulting from the grouping of focus regions, said rating of focus region groups is rating the focus region groups based on size of the group, a larger focus region group is rated as preferred in view of a smaller focus region group, selecting a focus region group or one or more focus region(s) included in a focus region group as a focus region based on said rating of focus region groups, running a focus searching algorithm starting searching at the lens distance value of the calculated local maximum of the focus value in the selected focus region, and setting the lens distance value to the lens distance value found by the focus searching algorithm. repeatedly setting a focus distance of the camera to focus at different distances by setting a lens distance of the camera to different lens distance values, determining, in response to setting a lens distance, a focus value for each focus region at the set lens distance value, characterized in estimating, when a plurality of focus value and lens distance value pairs have been determined, a function of at least degree two for each of a plurality of focus regions, wherein the function represents focus values as a function of lens distance values, calculating, for each focus region for which the function has been estimated, a local maximum point of the function, the local maximum point having a lens distance value, grouping focus regions based on the lens distance value of the local maximum point of the focus regions and spatial distances between the focus regions, rating the focus region groups resulting from the grouping of focus regions, said rating of focus region groups is rating the focus region groups based on size of the group, a larger focus region group is rated as preferred in view of a smaller focus region group, selecting a focus region group or one or more focus region(s) included in a focus region group as a focus region based on said rating of focus region groups, running a focus searching algorithm starting searching at the lens distance value of the calculated local maximum of the focus value in the selected focus region, and setting the lens distance value to the lens distance value found by the focus searching algorithm.