Request

class Request

Bases: pybind11_object

This the request that will transit on the network.

Example request decoding an image on a specific form. First parameter : Height of the image. Second parameter : Width of the image. Thirs parameter : Bitmap of the image (not compress).

Here is the header of the vpRequestImage class.

#ifndef vpRequestImage_H
#define vpRequestImage_H

#include <visp3/core/vpImage.h>
#include <visp3/core/vpRequest.h>

class vpRequestImage : public vpRequest
{
private:
  vpImage<unsigned char> *I;

public:
  vpRequestImage();
  vpRequestImage(vpImage<unsigned char> *);
  virtual ~vpRequestImage();

  virtual void encode();
  virtual void decode();
};

#endif

Here is the definition of the vpRequestImage class.

#include <vpRequestImage.h>

vpRequestImage::vpRequestImage(){
  request_id = "image";
}

vpRequestImage::vpRequestImage(vpImage<unsigned char> *Im){
  request_id = "image";
  I = Im;
}

vpRequestImage::~vpRequestImage(){}

void vpRequestImage::encode(){
  clear();

  unsigned int h = I->getHeight();
  unsigned int w = I->getWidth();

  addParameterObject(&h);
  addParameterObject(&w);
  addParameterObject(I->bitmap,h*w*sizeof(unsigned char));
}

void vpRequestImage::decode(){
  if(listOfParams.size() == 3){
    unsigned int w, h;
    memcpy((void*)&h, (void*)listOfParams[0].c_str(), sizeof(unsigned int));
    memcpy((void*)&w, (void*)listOfParams[1].c_str(), sizeof(unsigned int));

    I->resize(h,w);
    memcpy((void*)I->bitmap,(void*)listOfParams[2].c_str(),w*h*sizeof(unsigned char));
  }
}

Note

See vpClient

Note

See vpServer

Note

See vpNetwork

Methods

__init__

addParameter

Overloaded function.

clear

Clear the parameters of the request.

getId

Get the ID of the request.

setId

Change the ID of the request.

size

Get the number of parameters.

Inherited Methods

Operators

__doc__

__init__

__module__

Attributes

__annotations__

__init__(*args, **kwargs)
addParameter(*args, **kwargs)

Overloaded function.

  1. addParameter(self: visp._visp.core.Request, params: str) -> None

Add a message as parameter of the request.

Note

See vpNetwork::addParameterObject()

Parameters:
params

Array of characters representing the message to add.

  1. addParameter(self: visp._visp.core.Request, params: str) -> None

Add a message as parameter of the request.

Note

See vpNetwork::addParameterObject()

Parameters:
params

std::string representing the message to add.

  1. addParameter(self: visp._visp.core.Request, listOfparams: list[str]) -> None

Add messages as parameters of the request. Each message corresponds to one parameter.

Note

See vpNetwork::addParameterObject()

Parameters:
listOfparams

Array of std::string representing the messages to add.

clear(self) None

Clear the parameters of the request.

getId(self) str

Get the ID of the request.

Returns:

ID of the request.

setId(self, id: str) None

Change the ID of the request.

Note

See vpRequest::getId()

Parameters:
id: str

new ID.

size(self) int

Get the number of parameters.

Returns:

Number of parameters.