Package: landingai
LandingLens Python SDKThe LandingLens Python SDK contains the LandingLens development library and examples that show how to integrate your app with LandingLens in a variety of scenarios. The examples cover different model types, image acquisition sources, and post-procesing techniques.DocumentationLanding AI Python SDK DocsLanding AI Support CenterLandingLens Walk-Through VideoQuick startInstallFirst, install the Landing AI Python library:pipinstalllandingaiAcquire Your First ImagesAfter installing the Landing AI Python library, you can start acquiring images from one of many image sources.For example, from a single image file:fromlandingai.pipeline.framesetimportFrameframe=Frame.from_image("/path/to/your/image.jpg")frame.resize(width=512,height=512)frame.save_image("/tmp/resized-image.png")You can also extract frames from your webcam. For example:fromlandingai.pipeline.image_sourceimportWebcamwithWebcam(fps=0.5)aswebcam:forframeinwebcam:frame.resize(width=512,height=512)frame.save_image("/tmp/webcam-image.png")To learn how to acquire images from more sources, go toImage Acquisition.Run InferenceIf you have deployed a computer vision model in LandingLens, you can use this library to send images to that model for inference.For example, let's say we've created and deployed a model in LandingLens that detects coffee mugs. Now, we'll use the code below to extract images (frames) from a webcam and run inference on those images.[!NOTE]
If you don't have a LandingLens account, create onehere. You will need to get an "endpoint ID" and "API key" from LandingLens in order to run inferences. Check ourRunning Inferences / Getting Started.[!NOTE]
Learn how to use LandingLens from ourSupport CenterandVideo Tutorial Library.
Need help with specific use cases? Post your questions in ourCommunity.fromlandingai.pipeline.image_sourceimportWebcamfromlandingai.predictimportPredictorpredictor=Predictor(endpoint_id="abcdef01-abcd-abcd-abcd-01234567890",api_key="land_sk_xxxxxx",)withWebcam(fps=0.5)aswebcam:forframeinwebcam:frame.resize(width=512)frame.run_predict(predictor=predictor)frame.overlay_predictions()if"coffee-mug"inframe.predictions:frame.save_image("/tmp/latest-webcam-image.png",include_predictions=True)ExamplesWe've provided some examples in Jupyter Notebooks to focus on ease of use, and some examples in Python apps to provide a more robust and complete experience.ExampleDescriptionTypePoker Card Suit IdentificationThis notebook shows how to use an object detection model from LandingLens to detect suits on playing cards. A webcam is used to take photos of playing cards.Jupyter NotebookDoor Monitoring for Home AutomationThis notebook shows how to use an object detection model from LandingLens to detect whether a door is open or closed. An RTSP camera is used to acquire images.Jupyter NotebookSatellite Images and Post-ProcessingThis notebook shows how to use a Visual Prompting model from LandingLens to identify different objects in satellite images. The notebook includes post-processing scripts that calculate the percentage of ground cover that each object takes up.Jupyter NotebookLicense Plate Detection and RecognitionThis notebook shows how to extract frames from a video file and use a object detection model and OCR from LandingLens to identify and recognize different license plates.Jupyter NotebookStreaming VideoThis application shows how to continuously run inference on images extracted from a streaming RTSP video camera feed.Python applicationRun Examples LocallyAll the examples in this repo can be run locally.To give you some guidance, here's how you can run thertsp-captureexample locally in a shell environment:Clone the repo to local:git clone https://github.com/landing-ai/landingai-python.gitInstall the library:poetry install --with examples(See thepoetry docsfor how to installpoetry)Activate the virtual environment:poetry shellRun:python landingai-python/examples/capture-service/run.py