tweigel-dev / python-tuio

This repository is a python3 implementation of the TUIO protocol.
MIT License
3 stars 4 forks source link

how i can define my custom objects #11

Closed Elabbasy00 closed 3 years ago

Elabbasy00 commented 4 years ago

I am using reacT vision Tuio Simulator for experiment purpose How do I define my own objects for the actual touch screen experience

tweigel-dev commented 4 years ago

Hay, thanks for your issue. What did you mean with "own object"?

Which data structure would you like to transfer through TUIO?

Elabbasy00 commented 4 years ago

hi thanks for fast replay I own a touchscreen monitor from a company that displays its screen with object recognition, but it only works on its objects I am trying to do the same but with my own trangible object How can I say that the object with an angle of the triangle 100 object number 1 and so on

... If you are having trouble understanding what I am writing then I will try as much as possible to clear it up, but sorry, I am really new and tried every way to do it and this is not working.

tweigel-dev commented 4 years ago

at first it is important to understand which data you want to send through the TUIO protocol to your client. What did you mean with How can I say that the object with an angle of the triangle 100 object number 1 and so on ? Here can you find the specification of the protocol, maybe this can help you: https://www.tuio.org/?specification

maybe i dont understand you, because i dont know what reacTvision dose.

Elabbasy00 commented 4 years ago

Forget about the ReactVision My problem is that I cannot make the code work with specific object styles Like the picture, the object has top corners. These angles are written in the code while adding a specific object to the touch screen showing a specific interface

FLLUP35IT22N6L0

Can I put an app link that implements the idea or will that be boring? ... Always thanks for your response

Elabbasy00 commented 4 years ago

like Simulator every object have a unique id when i add one to the circle tuio fire listener and this work in you project very well i need convert this to actual object

Untitled image above from reacTvision TuioSimulator

tweigel-dev commented 4 years ago

okay, you have dedicated thinks which you can detect and want to send the location and angle to the client. for this case you can use the tuio OBJECT. Just add a new Object give it an unique id and the type you detects: Just a code example for the usage of Object:

    from pythontuio import TuioServer
    from pythontuio import Object
    server = TuioServer()
    object = Object(123) # sets session_id | object_id to 123
    object.class_id= 1 # for 1=star 2=circle  ... choose your own
    object.position=(0.3, 0.2) # has to be normalized beween 0->1
    object.angle= 30
    server.cursors.append(object)
    server.send_bundle()

The code is mainly tested with CURSOR at the moment. If there is something happening weird I will try to fix it.

Elabbasy00 commented 4 years ago

There is no need to modify anything inside pythontuio package

Elabbasy00 commented 4 years ago

This still works on normal objects only and it only works when I activate their program it does not work by itself Do you have any idea about this ..... To clarify more I cannot read any information about objects or cursor only when I execute their program even the objects specified by object = Object(115) object.angel = 30 object.position = (0.3, 0.2)

s

When I turn off their listener it stays like this 233

tweigel-dev commented 4 years ago

Can you share the hole code ? Did you sending the client and server data or is something send by the simulator?

Elabbasy00 commented 4 years ago

No, I have turned off all transmission related to any external simulator and nothing has been done except when I do Add a Tuio client in their own program

This ignores the objects added by me

`def test_dispatcher_listener():

client = TuioClient(("127.0.0.1", 3333))
t = Thread(target=client.start)

class MyListener(TuioListener):
    def add_tuio_cursor(self, cursor):
        print("detect a new Cursor")
        assert type(2) == type(cursor.session_id)
    def remove_tuio_cursor(self, cursor):
        print("Cursor disapered")
        assert type(2) == type(cursor.session_id)
    def update_tuio_cursor(self, cursor):
        print("recognize a Cursor")
        assert type(2) == type(cursor.session_id)

    def add_tuio_object(self, obj):
        print("tuio object add")
    def update_tuio_object(self, obj):
        print("update tuio object's")
        print(obj.angle)

listener = MyListener()
client.add_listener(listener)

t.start()

server = TuioServer()

cursor = Cursor(1213)
object = Object(1552)

object.angle = 30
object.class_id = 1
object.position = (0.3 , 0.2)

server.objects.append(object)
cursor.velocity             = (0.2,0.1)
cursor.motion_acceleration  = 0.1
server.objects.append(object)
server.cursors.append(cursor)
cursor.position  = (0.5,0.5)
server.send_bundle()
print("sented message")

`

tweigel-dev commented 4 years ago

This still works on normal objects only and it only works when I activate their program it does not work by itself Do you have any idea about this ..... To clarify more I cannot read any information about objects or cursor only when I execute their program even the objects specified by object = Object(115) object.angel = 30 object.position = (0.3, 0.2)

s

When I turn off their listener it stays like this 233

Here you are using a software of the table which implements a tuio server by itself . you have to programm a client, and open it to localhost. An the software of the table you have to config your client (ip and port). They should be in the same network.

Which information you can get by the table can be regonized by implementing all listener function at the client or by sniffing the UDP|OSC packages by software like wireshark.

Elabbasy00 commented 4 years ago

Can you explain more please? This table works on a PCP board, and I am connecting the HDMI connection to my laptop And here I use the same IP and port

client = TuioClient(("127.0.0.1", 3333))

Here is the client for your project

` class TuioClient(TuioDispatcher, BlockingOSCUDPServer): # pylint: disable=too-many-ancestors

def __init__(self, server_address: Tuple[str, int]): # pylint: disable=W0231
    TuioDispatcher.__init__(self)

    self._dispatcher = self
    self.connected = False
    self.server_address = server_address

def start(self):

    print(f"starting tuio-client at port {self.server_address[1]}")
    BlockingOSCUDPServer.__init__(self,self.server_address, self)
    self.serve_forever()  `

Is the missing part the wireshark partition?

Or should a new client be rebuilt and a connection with OSC

....

I apologize if this is out of range. It's the first time I'm building something like this. Thank you very much

tweigel-dev commented 4 years ago

I think we are misunderstanding each other. I will try to write what i think you want to do:

You have a Mutitouchtable which as an implementation of the server side of the TUIO protocol. This sends TUIO Bundles to a client. you want to implement this client. To do this, you are using this repo. (python-tuio)

there you have to run a client with an ip and a port. this ip and port gets inserted into your table. if you touches the table with your hand or some subjects the table sends some TUIO bundles to your client. Dose this work?

Elabbasy00 commented 4 years ago

Yes this is more clarification

I have a Mutitouchtable working on its own objects on its own system only I use python-tuio to control objects and cursor away from their natural behavior But what I found about operating this repo. (python-tuio) It only works when I add thier Client this make sense ?

tweigel-dev commented 4 years ago

The table has no tuio implementation but you have access to the data and want to sent them to your own client?

Elabbasy00 commented 4 years ago

@tweigel-dev This is exactly what I want What I'm doing right now is downloading a desktop app made by tabel makers in order to get the data

This app relies on listening to the same IP and port, but without it, I cannot get the data Can I send you a video or something similar?

tweigel-dev commented 3 years ago

Hay, did you figure out how you can use tuio for your purpose or is the issue still open? @Elabbasy00

Elabbasy00 commented 3 years ago

I haven't found a solution yet, but you can lock it Thank you so much