If you want to measure the amount of color an image has (in percentage), you can use the following repo:
https://github.com/Eitol/document_color_meter
If you want to measure the amount of color an image has (in percentage), you can use the following repo:
https://github.com/Eitol/document_color_meter
INCLUDEPATH += /usr/include/python2.7/
LIBS += -lpython2.7 -lbluetooth -lpthread
Nota que este ejemplo es para python 2.7. Debes verificar que versión de python tienes instalado en tu máquina. Si es distinto al 2.7 por ejemplo 2.5 entonces debes sustituir la versión en el string. Quedaría así:
INCLUDEPATH += /usr/include/python2.5/LIBS += -lpython2.5 -lbluetooth -lpthread
class BluetoothManager{
public:
void init(){
isOpen=true;
Py_Initialize();
main_module = PyImport_ImportModule("__main__");
main_dict = PyModule_GetDict(main_module);
PyRun_SimpleString(pycode_Init);
}
// Envia un string sin esperar respuesta
void sendAsync(QString data){
if (!isOpen){
perror("Error: puerto cerrado");
return;
}
if (!data.size()){
return;
}
// Concatena el string a enviar con el comando
PyRun_SimpleString(QString(QString("sock.send(\"")+data+"\\n\");\n").toLatin1().constData());
}
// Envia un string y espera la respuesta
QString sendSync(QString data){
if (!isOpen){
perror("Error: puerto cerrado");
return QString("");
}
if (!data.size()){
return QString("");
}
// Concatena el string a enviar con el comando
PyObject *data_py = NULL;
PyRun_SimpleString(QString(QString("sock.send(\"")+data+"\\n\");\n").toLatin1().constData());
usleep(150000);
PyRun_SimpleString("print(\"Recibe Data: \");\n");
PyRun_SimpleString("data = sock.recv(1024);\n");
PyRun_SimpleString("print \"received: \", data;\n");
data_py = PyMapping_GetItemString(main_dict, (char*)"data");
return QString(PyString_AsString(data_py));
}
void close(){
if (isOpen){
PyRun_SimpleString("sock.close();");
Py_Finalize();
isOpen=false;
}
}
~BluetoothManager(){
close();
}
private:
bool isOpen;
// Código para inicializar
const char * pycode_Init=
"from bluetooth import *;\n"
"server_address = \"00:13:01:05:06:73\";\n" // Mac de mi modulo
"port = 1;\n"
"sock = BluetoothSocket( RFCOMM );\n"
"sock.connect((server_address, port));\n"
"sock.settimeout(100.0);\n";
int t=0;
PyObject *main_module, *main_dict;
};
-----------------------------------
00:13:01:05:06:73 es la MAC de mi módulo bluetooth (hc-05). Debe sustituirla por su MAC.
Por ejemplo Ejemplo, para mandar un string asincronamente al bluetooth:
BluetoothManager bt;
bt.sendAsync("UN_STRING");