RoboCam Python Library

The RoboCam Python Library is a library that helps you easily use video streaming and video processing capabilities using RoboCam in Python.


You can install and use a library named RoboCam in a Python environment.

https://pypi.org/project/RoboCam/

▶Installation and deletion

Installation

The RoboCam will be installed when you execute the command below.

pip3 install RoboCam

The RoboCam will be updated to the latest version when the command below is executed.

pip3 install --upgrade RoboCam


Installing required libraries

Numpy library will be needed to deliver the recognition information. Run the command below to install numpy.

pip3 install numpy


The opencv2 library is required for image processing. The command below will install opencv2.

pip3 install opencv-contrib-python

Install and update opencv2 using the commands below.

pip3 install --upgrade opencv-contrib-python


Tensorflow lib

rary is needed for AI processing. Running the command below will install TensorFlow.

pip3 install tensorflow

You can install and update the tensorflow using the commands below.

pip3 install --upgrade tensorflow

Tflite library is needed for AI processing. Running the command below will install tflite.

pip3 install tflite

Install and update tflite using the command below.

pip3 install --upgrade tflite



Deletion

If the following command is pressed, RoboCam will be uninstalled.

pip3 uninstall RoboCam

▶Camera event

List of events that the RoboCam module can cause. It supports face detection, feature detection, ArUco marker detection, picture detection, and number detection.



class CameraEvents(enum.Enum):

  RECV_DETECTED_FACE_COUNT = 1

  RECV_DETECTED_FACE_NAME = 2

  RECV_DETECTED_FACE_RECT = 3

  RECV_LEFT_IRIS_POINT = 4

  RECV_LEFT_EYEBROW_POINT = 5

  RECV_RIGHT_IRIS_POINT = 5

  RECV_RIGHT_EYEBROW_POINT = 6

  RECV_NOSE_POINT = 7

  RECV_MOUSE_POINT = 8

  RECV_JAW_POINT = 9

  RECV_ARUCO_ID = 10

  RECV_ARUCO_IDS = 11

  RECV_ARUCO_CENTER_POINTS = 12

  RECV_ARUCO_RECT_POINTS = 13

  RECV_ARUCO_ANGLE = 14

  RECV_SKETCH_NAME = 15

  RECV_NUMBERS = 16

▶RoboCam Class

The generators of the RoboCam class are as follows.



def __init__(self):



It does not have a separate factor, and when you create an object, initialize each image recognition module and wait.



Also, the public function configuration of the RoboCam class is as follows.

Stream Function

1. CameraStreamInit( )

Name

: CameraStreamInit(width:int = 512, height:int = 512)


Explanation

A function that prepares you to stream RoboCam. It is streamed at a resolution of width x height.


Before calling the function, you must have a Wi-Fi connection with RoboCam. The default address for RoboCam is http://192.168.4.1:81/stream.


width

The horizontal resolution of the RoboCam.

Default : 512


height

The longitudinal resolution of the RoboCam.

Default: 512



2. CameraStream( )

Name

CameraStream()


Explanation

A function that starts streaming RoboCam's video.

You must use the CameraStreamInit function after calling it.



3.CameraStreamOff()

Name

: CameraStreamOff()


Explanation

A function that terminates the video streaming of RoboCam.



4. WebcamStreamInit( )

Name

: WebcamStreamInit(width:int = 640, height:int = 480)


Explanation

A function that prepares to stream Webcam. It is streamed at a resolution of width x height.

Before calling the function, it must be connected to the Webcam and USB.


width

The horizontal resolution of the RoboCam.

Default : 640


height

The longitudinal resolution of the RoboCam.

Default : 480



5. WebcamStream()

Name

: WebcamStream()


Explanation

A function that starts streaming the Webcam's image.

It should be used after the WebcamStreamInit function is called.


6.WebcamStreamOff()

Name

WebcamStreamOff()


Explanation

A function that ends Webcam's video streaming.



7. LeftRightFlipMode()

Name

LeftRightFlipMode(flag:bool)


Explanation

It is a function that reverses RoboCam's video streaming by flag.


flag

True: Left and right reversals ON, False: Left and right reversals OFF



8. UpDownFlipMode()

Name

UpDownFlipMode(flag:bool)


Explanation

It is a function that reverses RoboCam's video streaming up and down according to the flag.


flag

True: Left and right reversals ON, False: Left and right reversals OFF


9. MosaicMode()

Name

MosaicMode(rate:int)


Explanation

A function that sets the mosaic as a rate ratio in RoboCam's video streaming.


rate

The ratio of the image mosaic.

Unit: Percentage (%), Default: 0



10. RotateMode()

Name

RotateMode(angle:int)


Explanation

A function that rotates RoboCam's video streaming by angle.


angle

The angle of rotation of the image.

Unit: Angle (˚), Default: 90

Face Recognition Function

1. FacedetectorInit( )

Name

FacedetectorInit()


Explanation

A function that prepares RoboCam's face recognition module.

Initializes face detection, distinction, and feature recognition.


2. FacedetectorStart( )

Name

: FacedetectorStart()


Explanation

A function that executes the face detection module.

It recognizes the face inside the RoboCam screen and displays a rectangle on the outline.

Small circles are displayed in the coordinates of the features such as eyes, nose, and mouth.

If there is any trained data, it displays the name of the recognized face data compared to the trained data.


3. FacedetectorStop( )

Name

: FacedetectorStop()


Explanation

A function that stops the face detection module.



4. GetFaceCount( )

Name

GetFaceCount() -> int


Explanation

A function that shows the number of faces recognized on the streamed screen.



5. GetFaceRects( )

Name

GetFaceRects() -> list


Explanation

A function that returns the coordinates of the outer rectangle that displays the recognized face on the streamed screen.



6. DrawFaceArea( )

Name

DrawFaceArea(flag:bool)


Explanation

A function that determines whether the area of the recognized face is displayed on the streamed screen.


7. DrawFacePoint( )

Name

DrawFacePoint(flag:bool)


Explanation

A function that determines whether the coordinates of the recognized face are displayed on the streamed screen.



8. DrawFaceSize( )

Name

DrawFaceSize(flag:bool)


Explanation

A function that determines whether the size of the recognized face is displayed on the streamed screen.


9. FaceCapture( )

Name

: FaceCapture(name:str, captureCount:int=5, path:str)


Explanation

A function that captures the detected face as many times as the name captureCount and stores it in the path position.

The saved faces are used as training data for the face identification module. If the face is not recognized on the RoboCam screen, it will not be saved.


name

The name where the face will be saved. If you save it multiple times with the same name, it will be automatically numbered and saved.


captureCount

Number of times you want to save your face. Save as many times as specified at 0.1-second intervals.


path

The path where the face will be stored. The default path is '/res/face/' in the package installation path.

If you save by changing the storage path, you must set it to the changed path when learning the module.


10. TrainFaceData( )

name

: TrainFaceData(facePath:str)


Explanation

A function that trains the face data stored in the facepath to the face identification module.

Based on the trained data, RoboCam displays the name of the identified face.


facePath

The path where the face will be stored. The default path is '/res/face/' in the package installation path.

If you save by changing the storage path, you must set it to the changed path when learning the module.




11. DeleteFaceData( )

Name

: DeleteFaceData(name:str, facePath:str)


Explanation

A function that deletes face data with the name stored in facepath.

Access the folder and delete the data. After deleting the data, the TrainFaceData function must be called to be applied to the face identification module.



12. GetFaceNames( )

Name

GetFaceNames() -> list


Explanation

A function that returns the names of faces identified in RoboCam in the form of a list.

If no faces are currently recognized, return a blank list.



13. GetFaceExist( )

Name

GetFaceExist(name:str) -> bool


Explanation

A function that returns whether any of the recognized faces in RoboCam have a name.


name

The name of the face to be detected.



14. GetFaceSize( )

Name

GetFaceSize(name:str) -> int


Explanation

A function that returns the size of the face with the name among the faces recognized by RoboCam.


name

The name of the face to be sized.

If not, returns the size of the unlearned face.



15. GetFaceCenterPoint( )

Name

GetFaceSize(name:str) -> int


Explanation

A function that returns the central coordinate of the face with the name among the faces recognized in RoboCam.


name

The name of the face from which to retrieve the coordinates.

If not, returns the size of the unlearned face.



16. DrawFaceName( )

Name

DrawFaceName(flag:bool)


Explanation

A function that determines whether the name of the recognized face is displayed on the streamed screen.



17. GetLeftIrisPoint( )

Name

GetLeftIrisPoint(name:str)->list


Explanation

A function that returns the coordinates of the left pupil of the face identified in RoboCam.


name

The name of the face to be detected.



18. GetLeftEyebrowPoint( )

Name

GetLeftEyebrowPoint(name:str)->list


Explanation

A function that returns the coordinates of the left eyebrow of the face identified in RoboCam.


name

The name of the face to be detected.


19. GetRightIrisPoint( )

Name

GetRightIrisPoint(name:str)->list


Explanation

A function that returns the coordinates of the right pupil of the face identified in RoboCam.


name

The name of the face to be detected.



20. GetRightEyebrowPoint( )

Name

: GetRightEyebrowPoint(name:str)->list


Explanation

A function that returns the coordinates of the right eyebrow of the face identified in RoboCam.


name

The name of the face to be detected.



21. GetNosePoint( )

Name

: GetNosePoint(name:str)->list


Explanation

A function that returns the coordinates of the nose of the face identified in RoboCam.


name

The name of the face to be detected.



22. GetMousePoint( )

Name

: GetMousePoint(name:str)->list


Explanation

A function that returns the coordinates of the mouth of the face identified in RoboCam.


name

The name of the face to be detected.



23. GetJawPoint( )

Name

: GetJawPoint(name:str)->list


Explanation

A function that returns the coordinates of the jaw of the face identified in RoboCam.


name

The name of the face to be detected.



24. DrawFaceLandmark( )

Name

DrawFaceLandmark(flag:bool)


Explanation

A function that determines whether the recognized features of the face are displayed on the screen

ArUco Marker Recognition Function

1. ArucoDetectorInit( )

Name

: ArucoDetectorInit()


Explanation

A function that initializes the Aruco marker navigation module.

Navigate to the Original Arucco target.


2. ArucoDetectorStart( )

Name

: ArucoDetectorStart()


Explanation

A function that runs the Aruco marker navigation module.




3. ArucoDetectorStop( )

Name

: ArucoDetectorStop()


Explanation

A function that stops the Acuro marker navigation module.



4. GetArucoId( )

Name

GetArucoId() -> int


Explanation

A function that returns the unique number of the Arucco marker recognized in RoboCam in int form.



5. GetArucoIds( )

Name

GetArucoIds()-> list


Explanation

A function that returns the unique numbers of the Arucco markers recognized in RoboCam in the form of a list.



6. GetArucoCenterPoint( )

Name

GetArucoCenterPoint(id:int) -> list


Explanation

A function that returns the center coordinates of the recognized Arucco marker in the form [X,Y] in RoboCam.


id

ID of the Marker to be detected.



7. GetArucoCount( )

Name

GetArucoCount() -> int


Explanation

A function that returns the number of recognized Arucco markers in RoboCam.



8. GetSketchExist( )

Name

GetArucoExist(id:int) -> bool


Explanation

A function that returns the result value to see if any of the Aruco markers recognized in RoboCam, which matches the id.



9. GetArucoX( )

Name

GetArucoX(id:int) -> int


Explanation

Among the Aruco markers recognized in RoboCam, a function that returns the X coordinates of the marker corresponding to id.



10. GetArucoY( )

Name

: GetArucoY(id:int) -> int


Explanation

Among the Aruco markers recognized in RoboCam, a function that returns the Y coordinate of the marker corresponding to id.



11. GetArucoDistance( )

Name

: GetArucoDistance(id:int) -> int


Explanation

Among the Aruco markers recognized in RoboCam, a function that returns the distance from the marker corresponding to id.



12. GetArucoRectPoint( )

Name

GetArucoRectPoint(id:int) -> list


Explanation

Among the Aruco markers recognized in RoboCam, a function that returns the four-corner coordinates of the marker corresponding to id in the form [X1,Y1, [X2,Y2], [X3,Y3], [X4,Y4]].



13. GetArucoAngle( )

Name

: GetArucoAngle()->float


Explanation

The function of the recognized Aruco marker in the RoboCam returning the tilted angle.


14. DrawArucoArea( )

Name

DrawArucoArea(flag:bool)


Explanation

A function that determines whether to display the area of the recognized Aruco marker.


15. DrawArucoId( )

Name

DrawArucoId(flag:bool)


Explanation

A function that determines whether to display the ID of the recognized Aruco marker.



16. DrawArucoPoint( )

Name

: DrawArucoPoint(flag:bool)


Explanation

A function that determines whether to display the coordinates of the recognized Aruco marker.



17. DrawArucoDistance( )

Name

: DrawArucoDistance(flag:bool)


Explanation

A function that determines whether to display the distance of the recognized Arucco marker.



18. DrawArucoSize( )

Name

: DrawArucoSize(flag:bool)


Explanation

A function that determines whether to display the size of the recognized Arucco marker.

Drawing Recognition Function

1. SketchDetectorInit( )

Name

SketchDetectorInit()


Explanation

A function that prepares RoboCam's picture recognition module.

Learn and distinguish the picture drawn inside the black outer square.



2. SketchDetectorStart( )

Name

: SketchDetectorStart


Explanation

A function that starts the picture recognition module.

The RoboCam displays rectangles on the outside of the recognized picture.



3. SketchDetectorStop( )

Name

: SketchDetectorStop()


Explanation

A function that stops the picture recognition module.



4. SketchCapture( )

Name

: SketchCapture(name:str,captureCount:int=5,path:str)


Explanation

A function that captures the picture recognized in RoboCam with the name and stores it in path.

The stored picture data is used as the training data for the picture discrimination module. If the picture is not recognized on the RoboCam screen, it will not be saved.


name

The name where the picture will be saved. If you save it multiple times under the same name, it will be automatically numbered and saved.


captureCount

Number of times the picture will be saved. If not, save five pictures.


path

The path where the picture will be stored. The default path is '/res/sketch/' of the package installation path.



5. TrainSketchData( )

Name

: TrainSketchData(sketchPath:str)


Explanation

A function that trains the picture data stored in the sketchPath to the picture identification module.

Based on the learned data, RoboCam displays the name of the verified picture.


sketchPath

The path where the picture data will be stored. The default path is '/res/sketch/' of the package installation path.



6. DeleteSketchData( )

Name

: DeleteSketchData(name:str, sketchPath:str)


Explanation

A function that deletes picture data with the name stored in sketchPath.

Access the folder and delete the data. After deleting the data, the TrainFaceData function must be called to be applied to the picture separation module.



7. GetSketchNames( )

Name

: GetSketchNames()->list


Explanation

A function that returns the name of the picture recognized in RoboCam in the form of a list.



8. GetSketchExist( )

Name

GetSketchExist(name:str)->bool


Explanation

A function that returns whether any of the recognized pictures in RoboCam correspond to the name.



9. GetSketchCenterPoint( )

Name

GetSketchCenterPoint(name:str)->list


Explanation

Among the pictures recognized in RoboCam, a function that returns the coordinates of the picture corresponding to the name in the form of a list.



10. GetSketchSize( )

Name

GetSketchSize(name:str)->int


Explanation

Among the pictures recognized in RoboCam, a function that returns the size of the picture corresponding to the name.



11. DrawSketchArea( )

Name

: DrawSketchArea(flag:bool)


Explanation

A function that determines whether the area of the recognized picture is displayed.



12. DrawSketchName( )

Name

: DrawSketchName(flag:bool)


Explanation

Function that determines whether to display the name of the recognized picture.



13. DrawSketchSize( )

Name

DrawSketchSize(flag:bool)


Explanation

A function that determines whether to display the size of the recognized picture.



14. DrawSketchPoint( )

Name

DrawSketchPoint(flag:bool)


Explanation

A function that determines whether to display the coordinates of a recognized picture.