{"id":27287430,"url":"https://github.com/bhartik021/cognitivevissionapp","last_synced_at":"2025-04-11T20:19:48.286Z","repository":{"id":246882663,"uuid":"824521549","full_name":"bhartik021/cognitivevissionapp","owner":"bhartik021","description":"This application demonstrates how to use Azure's Computer Vision API with .NET to analyze images and extract descriptions.","archived":false,"fork":false,"pushed_at":"2024-07-05T14:30:44.000Z","size":463,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T20:19:45.229Z","etag":null,"topics":["azure-ai","cognitive-services","computer-vision","csharp","dotnet"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bhartik021.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-05T10:02:49.000Z","updated_at":"2024-08-27T02:45:11.000Z","dependencies_parsed_at":"2024-07-05T18:54:09.278Z","dependency_job_id":null,"html_url":"https://github.com/bhartik021/cognitivevissionapp","commit_stats":null,"previous_names":["bhartik021/cognitivevissionapp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhartik021%2Fcognitivevissionapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhartik021%2Fcognitivevissionapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhartik021%2Fcognitivevissionapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhartik021%2Fcognitivevissionapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bhartik021","download_url":"https://codeload.github.com/bhartik021/cognitivevissionapp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248473095,"owners_count":21109629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure-ai","cognitive-services","computer-vision","csharp","dotnet"],"created_at":"2025-04-11T20:19:47.498Z","updated_at":"2025-04-11T20:19:48.263Z","avatar_url":"https://github.com/bhartik021.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cognitive Vision App\n\nThis application demonstrates how to use Azure's Computer Vision API with .NET to analyze images and extract descriptions.\n\n### Features\n\n- Analyze images using Azure's Computer Vision API.\n- Extract descriptions from images with confidence levels\n\n## Prerequisites\n\n- .NET SDK installed on your machine. You can download it from [here](https://dotnet.microsoft.com/download).\n- Visual Studio Code or any other code editor.\n- An Azure subscription. If you don't have one, you can create a free account [here](https://azure.microsoft.com/free/).\n\n## Setup\n\n### 1. Clone the Repository\n\n```sh\ngit clone https://github.com/your-username/cognitive-vision-app.git\n```\n\n```sh\ncd cognitive-vision-app\n```\n\n\n### 2. Install the Required Packages\nOpen a terminal in the project directory and run:\n\n```sh\ndotnet add package Microsoft.Azure.CognitiveServices.Vision.ComputerVision\n```\n\n### 3. Create a Cognitive Services Resource on Azure\n- Go to the [Azure Portal](https://portal.azure.com/#home).\n- Click on \"Create a resource\" and search for \"Cognitive Services\".\n- Select \"Computer Vision\" and click \"Create\".\n- Fill in the necessary details and create the resource.\n- Once created, navigate to the resource and copy the API key and endpoint URL\n\n### 4. Configure the Application\nOpen `Program.cs` and replace `YOUR_SUBSCRIPTION_KEY` and `YOUR_ENDPOINT_URL` with the values you copied from Azure.\n\n```cs\nprivate const string subscriptionKey = \"YOUR_SUBSCRIPTION_KEY\";\nprivate const string endpoint = \"YOUR_ENDPOINT_URL\";\n```\n\n### 5. Run the Application\nIn the terminal, run the following command:\n\n```sh\ndotnet run\n```\n\n## Code Overview\nThe main functionality of the application is in `Program.cs`. The application uses the Azure Cognitive Services Computer Vision API to analyze an image and return a description.\n\n```cs\nusing Microsoft.Azure.CognitiveServices.Vision.ComputerVision;\nusing Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;\nusing System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\nclass Program\n{\n    private const string subscriptionKey = \"YOUR_SUBSCRIPTION_KEY\";\n    private const string endpoint = \"YOUR_ENDPOINT_URL\";\n\n    static async Task Main(string[] args)\n    {\n        try\n        {\n            ComputerVisionClient client = new ComputerVisionClient(new ApiKeyServiceClientCredentials(subscriptionKey))\n            {\n                Endpoint = endpoint\n            };\n\n            // Example image URL\n            string imageUrl = \"https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg\";\n\n            var features = new List\u003cVisualFeatureTypes?\u003e { VisualFeatureTypes.Description };\n            ImageAnalysis result = await client.AnalyzeImageAsync(imageUrl, features);\n\n            Console.WriteLine($\"Request ID: {result.RequestId}\");\n            Console.WriteLine($\"Metadata: {result.Metadata}\");\n            foreach (var caption in result.Description.Captions)\n            {\n                Console.WriteLine($\"Description: {caption.Text} with confidence {caption.Confidence}\");\n            }\n        }\n        catch (ComputerVisionErrorResponseException e)\n        {\n            Console.WriteLine($\"Computer Vision API error: {e.Message}\");\n            if (e.Body != null \u0026\u0026 e.Body.Error != null)\n            {\n                Console.WriteLine($\"Error Code: {e.Body.Error.Code}\");\n                Console.WriteLine($\"Error Message: {e.Body.Error.Message}\");\n            }\n        }\n        catch (Exception e)\n        {\n            Console.WriteLine($\"Unexpected error: {e.Message}\");\n        }\n    }\n}\n\n```\n\n## Troubleshooting\nIf you encounter any issues, please check the following:\n\n- Ensure your API key and endpoint URL are correct.\n- Verify the image URL is publicly accessible and in a supported format (JPEG, PNG, BMP, or GIF).\n- Check the Azure Cognitive Services pricing and usage limits.\n\n## Resources\n\n- [Azure Cognitive Services Documentation](https://docs.microsoft.com/en-us/azure/cognitive-services/)\n- [.NET Documentation](https://docs.microsoft.com/en-us/dotnet/)\n- [Azure Free Account](https://azure.microsoft.com/free/)\n\n## License\nThis project is licensed under the MIT License. See the `LICENSE` file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhartik021%2Fcognitivevissionapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbhartik021%2Fcognitivevissionapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhartik021%2Fcognitivevissionapp/lists"}