Пример #1
0
def test_detection_file():

    detection = Detection(config, name="mask")

    res = detection.detectObject(os.path.join(IMAGES_DIR, "pelosi.webp"))

    assert len(res) == 1
Пример #2
0
def test_detection_file():

    detection = Detection(config)

    res = detection.detectObject(os.path.join(IMAGES_DIR, "detection.jpg"))

    assert len(res) == 3
Пример #3
0
def test_detection_url():

    detection = Detection(config)

    res = detection.detectObject(
        "https://docs.deepstack.cc/_images/family-and-dog.jpg")

    assert len(res) == 3
Пример #4
0
def test_detection_pil():

    detection = Detection(config, name="mask")

    img = Image.open(os.path.join(IMAGES_DIR, "pelosi.webp"))

    res = detection.detectObject(img)

    assert len(res) == 1
Пример #5
0
def test_detection_cv2():

    detection = Detection(config, name="mask")

    img = cv2.imread(os.path.join(IMAGES_DIR, "pelosi.webp"))

    res = detection.detectObject(img)

    assert len(res) == 1
Пример #6
0
def test_detection_pil():

    detection = Detection(config)

    img = Image.open(os.path.join(IMAGES_DIR, "detection.jpg"))

    res = detection.detectObject(img)

    assert len(res) == 3
Пример #7
0
def test_detection_cv2():

    detection = Detection(config)

    img = cv2.imread(os.path.join(IMAGES_DIR, "detection.jpg"))

    res = detection.detectObject(img)

    assert len(res) == 3
Пример #8
0
def test_detection_bytes():

    detection = Detection(config)

    img = Image.open(os.path.join(IMAGES_DIR, "detection.jpg"))

    img_data = pilToBytes(img)

    res = detection.detectObject(img_data)

    assert len(res) == 3
Пример #9
0
from deepstack_sdk import Detection, ServerConfig
import os

config = ServerConfig("http://localhost:80")
detector = Detection(config=config, name="dark")

detections = detector.detectObject(image=os.path.join("images", "image.jpg"),
                                   output=os.path.join("images",
                                                       "image_detected.jpg"))

for detection in detections:
    print("Name: {}".format(detection.label))
    print("Confidence: {}".format(detection.confidence))
    print("x_min: {}".format(detection.x_min))
    print("x_max: {}".format(detection.x_max))
    print("y_min: {}".format(detection.y_min))
    print("y_max: {}".format(detection.y_max))
    print("-----------------------")
Пример #10
0
from deepstack_sdk import ServerConfig, Detection
import cv2

config = ServerConfig("http://localhost:80")
detection = Detection(config)

cv2_image = cv2.imread("image.jpg")
response = detection.detectObject(cv2_image, output="image_output.jpg")

for obj in response:
    print(
        "Name: {}, Confidence: {}, x_min: {}, y_min: {}, x_max: {}, y_max: {}".
        format(obj.label, obj.confidence, obj.x_min, obj.y_min, obj.x_max,
               obj.y_max))
from deepstack_sdk import ServerConfig, Detection

config = ServerConfig("http://localhost:80")
detection = Detection(config)

response = detection.detectObject("image.jpg", output="image_output.jpg")

for obj in response:
    print(
        "Name: {}, Confidence: {}, x_min: {}, y_min: {}, x_max: {}, y_max: {}".
        format(obj.label, obj.confidence, obj.x_min, obj.y_min, obj.x_max,
               obj.y_max))
"""
:: detection.detectObject()

--- Available Paramaters

- image (file, numpy array, PIL Image, image bytes, url)
- format (jpg, png)
- min_confidence (0.1 to 1.0)
- callback (function name, parses in image_byte [without label and boxes] and detections into the function)
- output (file path of none if you don't want to save to file)
- output_font (cv2 font)
- output_font_color ( r, g, b )
"""
from deepstack_sdk import ServerConfig, Detection


def detection_callback(input_image_byte, detection_result):
    # Get detected image byte and save
    with open("detected_image.jpg", "wb") as writer:
        writer.write(input_image_byte)
    
    # Process detection result
    for obj in detection_result:
        print("Name: {}, Confidence: {}, x_min: {}, y_min: {}, x_max: {}, y_max: {}".format(obj.label, obj.confidence, obj.x_min, obj.y_min, obj.x_max, obj.y_max))

    # You can do other stuffs with the image and the detection results in this function
    

config = ServerConfig("http://localhost:80")
detection = Detection(config)

image_byte = open("image.jpg", "rb").read()
response = detection.detectObject(image_byte, callback=detection_callback)
from deepstack_sdk import ServerConfig, Detection

config = ServerConfig("http://localhost:80")
detection = Detection(config)

image_byte = open("image.jpg", "rb").read()
response = detection.detectObject(image_byte,output="image_output.jpg")

for obj in response:
    print("Name: {}, Confidence: {}, x_min: {}, y_min: {}, x_max: {}, y_max: {}".format(obj.label, obj.confidence, obj.x_min, obj.y_min, obj.x_max, obj.y_max))
Пример #14
0
from deepstack_sdk import ServerConfig, Detection

config = ServerConfig("http://localhost:89")
detection = Detection(config)

response = detection.detectObject("detection.jpg", output="output_image.jpg")

for obj in response:
    print("Name: {}, Confidence: {}".format(obj.label, obj.confidence))