Blender scripting: Circle Selectiong in the "3D View" In Blender2.74, I want to circle-select the vertices in the "3D View", using this: circle_select(x = 300, y = 400, radius = 30). 



I found this question. So I know how to get the xy positions in the camera coordinate system.

Now I don't know how to use the API "bpy.ops.view3d.select_circle()". 
When I used the command in python console, the following error occured.

bpy.ops.view3d.select_circle(x=500, y=500, radius=10)
Traceback (most recent call last):
File "&lt;blender_console&gt;", line 1, in &lt;module&gt;
File "C:\Program Files\Blender Foundation\Blender\2.74\scripts\modules\bpy\ops.py", 
line 189, in __call__
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.view3d.select_circle.poll() expected a view3d region


Can I use this API in the "Python Console?

And, I will probably have to convert the xy positions in the camera-cood to those in the "3D View". Please teach me this also.
You have to override the context to be able to call this operator outside of the 3d view :

import bpy



for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':

        override = bpy.context.copy()
        override['area'] = area
        override['region'] = area.regions[4]

        bpy.ops.view3d.select_circle(override, x=300, y=150, radius=300, gesture_mode = 3)
        break




Update : Finding the camera corners coordinates

import bpy
from bpy_extras import view3d_utils, object_utils

scene = bpy.context.scene
cam = scene.camera

for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        viewport = area.regions[4]
        rv3d = area.spaces[0].region_3d
        P1 = (0,0)
        P2 = (viewport.width, viewport.height)

        depth_location =  view3d_utils.region_2d_to_vector_3d(viewport, rv3d, P1)
        p = view3d_utils.region_2d_to_location_3d(viewport, rv3d, P1, depth_location)
        P1cam  = object_utils.world_to_camera_view(scene, cam, p)


        depth_location =  view3d_utils.region_2d_to_vector_3d(viewport, rv3d, P2)
        p = view3d_utils.region_2d_to_location_3d(viewport, rv3d, P2, depth_location)
        P2cam  = object_utils.world_to_camera_view(scene, cam, p)


        cam_width = int(P2[0]/(P2cam[0]-P1cam[0]))
        cam_x = int(-1*P1cam[0]*cam_width)

        cam_height = int(P2[1]/(P2cam[1]-P1cam[1]))
        cam_y = int(-1*P1cam[1]*cam_height)

        print(cam_width, cam_height, cam_x, cam_y)
        print("\nP(0,0) at (%d, %d) and P(1920, 1080) at ( %d, %d)"%(cam_x, cam_y, cam_x+cam_width, cam_y+cam_height) )