public GPhotoCamera()
	{
		context = new Context();

		port_info_list = new PortInfoList ();
		port_info_list.Load ();
			
		abilities_list = new CameraAbilitiesList ();
		abilities_list.Load (context);
			
		camera_list = new CameraList();
			
		selected_camera__camera_list_index = -1;

		camera = null;
		port_info = null;
		camera_fs = null;
	}
Пример #2
0
        /// <summary>
        /// Detects all usable cameras which are connected to the system
        /// </summary>
        /// <returns>A list containing all cameras which can be connected to</returns>
        public static List<Camera> Detect()
        {
            if (Utilities.Is64Bit && Environment.OSVersion.Platform != PlatformID.Unix)
            {
                Console.WriteLine("A 64bit windows system has been detected. This is not supported");
                Console.WriteLine("due to the complexity of interoperating with libgphoto2");
                Console.WriteLine("as it exposes variable length 'long' types in it's API.");
                Console.WriteLine("The API is unlikely to change before version 3 of the library");
                Console.WriteLine("The current status of this can be found on the libgphoto2");
                Console.WriteLine("mailing list. A detailed explanation can be found in the");
                Console.WriteLine("README file for libgphoto2-sharp");
                return new List<Camera>();
            }

            List<Camera> cameras = new List<Camera>();
            Context c = new Context();

            using (CameraAbilitiesList abilities = new CameraAbilitiesList())
            using (PortInfoList portInfoList = new PortInfoList())
            using (CameraList cameraList = new CameraList())
            {
                // Get the list of all devices that are currently supported
                abilities.Load(c);

                // Get the list of all the (usb?) ports that are currently available
                portInfoList.Load();

                // Create the list of all the connected devices which can be used
                abilities.Detect(portInfoList, cameraList, c);

                // Scan through all the detected cameras and remove any duplicates
                using (CameraList cams = RemoveDuplicates(cameraList))
                {
                    int count = cams.Count();
                    for(int i = 0; i < count; i++)
                    {
                        CameraAbilities ability = abilities.GetAbilities(abilities.LookupModel(cams.GetName(i)));
                        PortInfo portInfo = portInfoList.GetInfo(portInfoList.LookupPath(cams.GetValue(i)));
                        cameras.Add(new Gphoto2.Camera(ability, portInfo, c));
                    }
                }
            }

            return cameras;
        }