Network¶
Main app for the communication with the C# Wrapper.
Instance¶
-
class
src.network.instance.Instance(*args)¶ Class Instance
-
activate_metrology(configuration_id)¶ Activates the given metrology.
- Arguments:
configuration_id (int): Id of the metrology to activate
- Returns:
bool: Return if the metrology is activated
-
add_DXF(mode)¶ Adds a DXF mode to the Instance.
- Arguments:
mode (int): Mode to use (0: ‘CUTTING’, 1: ‘STACKING’)
-
add_FOD_reference(name, reference_image)¶ Adds a FOD reference with the given name.
- Arguments:
name (str): Name of the reference reference_image (Image): Reference image
-
add_image(image, normalized=True)¶ Adds image to the Instance last layer and computes its displacement matrix. If this image is too close in real distance (<5mm) to the last one, the image is delete.
- Arguments:
image (Image): New image to add normalized (bool, optional): If the image must be normalized. Defaults to True.
-
calibrate(configuration_id, image, real_roi_length, real_roi_width)¶ Computes the calibration on the given image and saves it as the “configuration_id” configuration.
- Arguments:
configuration_id (int): Id used to save the configuration image (Image): Image used to compute all the calibration parameters real_roi_length (int): Real length of the chessboard real_roi_width (int): Real width of the chessboard
- Returns:
bool: Return True if success
-
detect_FOD(name, image)¶ Computes the FOD detection.
- Arguments:
name (str): Name of the image, used for finding the good reference to use image (Image): Image on which the detection is computed
- Returns:
bool: If there are FOD on the frame Image: Image with detected FOD drawn
-
get_DXF_image(name='ALL')¶ Returns the image of the chosen ply.
- Arguments:
name (str, optional): Name of th ply to return. Defaults to “ALL”.
- Returns:
numpy.ndarray: Image of the chosen ply
-
get_image()¶ Returns the image at the given index.
- Arguments:
index (int, optional): Index of the image in the last layer. Defaults to -1.
- Returns:
Image: Image at the given index
-
get_layer(index=- 1)¶ Returns the chosen layer.
- Arguments:
index (int, optional): Index of the layer to return. Defaults to -1.
- Returns:
Layer: Layer to return
-
get_layers()¶ Returns all the layers of the Instance.
- Returns:
numpy.ndarray: Array of Layer
-
get_orientation(image)¶ Computes the orientation calculation on the given image.
- Arguments:
image (Image): Image on which the orientation will be calculated
- Returns:
int: Orientation value (in degrees)
Image: Rotated image
-
get_shooting_positions(request_mode, width=115, height=80, overlap=4600)¶ Returns the shooting position.
- Arguments:
request_mode (int): Request mode
width (int, optional): Real width in mm of the calibration image. Defaults to 115.
height (int, optional): Real height in mm of the calibration image. Defaults to 80.
overlap (int, optional): Number of pixels that overlaps. Defaults to 4600.
- Returns:
numpy.ndarray: Coordinates [x, y]
-
get_stacking_plies()¶ Returns the plies in the DXF.
- Returns:
numpy.ndarray: List of plies
-
is_calibrated()¶ Checks if the metrology is calibrated.
- Returns:
bool: True if the metrology is calibrated
-
mm_to_px(value)¶ Converts value from mm to pixel.
- Arguments:
value (int): Value to convert
- Returns:
int: Converted value
-
new_layer()¶ Adds a new layer to the Instance.
-
normalize(input_image)¶ Normalizes with the calibration file.
- Arguments:
input_image (Image): Image which will be normalized
- Returns:
Image: Image normalized
-
one_shot_plies_detection(higly_contrasted_image)¶ Computes the plies detection on one frame.
- Arguments:
higly_contrasted_image (Image): Image used for the plies detection
- Returns:
Image: Image with the contours drawn and the name of the identified plies
-
px_to_mm(value)¶ Converts value from pixel to mm.
- Arguments:
value (int): Value to convert
- Returns:
int: Converted value
-
reset_DXF_manager()¶ Resets the DXF manager.
-
set_ip(new_ip)¶ Sets Instance ip.
- Arguments:
new_ip (str): New ip adress
-
set_parameters(params)¶ Sets Instance parameters.
- Arguments:
params (dict): Dictionary of flags
-
Listener¶
-
class
src.network.listener.Listener¶ Listener class for the connection with other software.
-
activate_metrology()¶ Receives the id of the metrology to activate and activates it. Sends if the metrology has been correctly activated.
-
add_reference()¶ Receives a name and an image and adds them as reference for FOD detection.
-
calibrate()¶ Receives an image and computes calibration with it.
-
connection_lost(exc)¶ Called when the connection is lost or closed.
The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed).
-
connection_made(transport)¶ Called when a connection is made.
The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.
-
detect_FOD()¶ Receives a name and an image and computes with them the FOD detection. Sends back the number of FODs and the image with the detected FODs.
-
disconnect()¶ Called when the other side is disconnected.
-
fiber_orientation()¶ Receives a name and an image and computes with them the orientation function. Sends back the angle and the rotated image.
-
get_image()¶ Called to receive image and to put it in the right format.
- Returns:
Image: Received image
-
get_image_and_coordinates()¶ Called to receive image and its coordinates and to put them in the right format.
- Returns:
Image: Received image with the received coordinates.
-
get_text()¶ Called to receive text and to put it in the right format.
- Returns:
str: Received text
-
listen()¶ Listens to orders and executes them.
-
local_fiber_orientation()¶ Receives a name and an image and computes with them the local orientation function. Sends back the angle and the rotated image.
-
mm_to_px()¶ Receives data and converts it from mm value to pixel value. And sends it back.
-
normalize()¶ Receives an image and normalizes it. And sends it back.
-
one_shot_plies_detection()¶ Receives an image and calls with it the plies detection. Sends the resulting image and the detected plies informations.
-
px_to_mm()¶ Receives data and converts it from pixel value to mm value. And sends it back.
-
receive(size, return_receipt=True, resending_counter=0)¶ Receives the data with the size “size” and sends a code if the CRC check is good.
- Arguments:
size (int): Size of the data to receive return_receipt (bool, optional): If data msut be resend due to a loss of information. Defaults to True. resending_counter (int, optional): Counter of resending, value between 0 and 3. Defaults to 0.
- Returns:
bool: If the data has been correctly received.
-
send(data)¶ Sends data.
- Arguments:
data (int, float, str, bool): data to send
- Returns:
bool: If the data has been correctly send and received.
-
send_DXF_image()¶ Sends the DXF image of the ply asked.
-
send_bytes(data, size, return_receipt=True, resending_counter=0)¶ Sends data in the form of bytes and computes the crc for the verification.
- Arguments:
data (int or str or float): Data to send size (int): Data size return_receipt (bool, optional): If data msut be resend due to a loss of information. Defaults to True. resending_counter (int, optional): Counter of resending, value between 0 and 3. Defaults to 0.
- Returns:
bool: If data has been correctly send and received
-
send_code(code, size=1)¶ Sends order code.
- Arguments:
code (int): Code to send size (int, optional): Size of the data. Defaults to 1.
-
send_detected_plies_informations()¶ Sends the informations of the detected plies (shape, position, angle, fiber_orientation).
-
send_image(image)¶ Sends image.
- Arguments:
image (Image): Image to send
-
send_output()¶ Sends the log output.
-
send_ping()¶ Sends ping.
-
send_plies_informations()¶ Sends plies informations (shape, position, angle, fiber_orientation).
-
send_ply(ply: src.processing_cores.descriptors.shape.RealPly)¶ Sends the given ply.
- Arguments:
ply (RealPly): Ply to send
-
send_shooting_positions()¶ Sends the shooting positions after receiving the view width and height and the overlapping area.
-
set_params()¶ Receives parameters and sets the instance parameters.
-
start_listening()¶ Called when a connection is made and starts to listen to the other side of the transport.
-
wait_code(code)¶ Waits until a specified code is received.
- Arguments:
code (int): Awaited code
-
wait_order()¶ Called to wait until an order is received.
- Returns:
int: Code order
-
write_DXF()¶ Writes DXF with the data received.
-