jsk-ros-pkg / jsk_3rdparty

42 stars 60 forks source link

[rostwitter] Support extracting base64 images and tweet them from text. #375

Closed iory closed 1 year ago

iory commented 2 years ago

What is this?

This is the another version of https://github.com/jsk-ros-pkg/jsk_3rdparty/pull/371 This PR is developed on https://github.com/jsk-ros-pkg/jsk_3rdparty/pull/373

smach to twitter uses cv2.imencode, so we need to do cv2.imdecode. https://github.com/jsk-ros-pkg/jsk_robot/blob/a87dbc1a8808d0d0aed9d06a5245e7cab2fe1e87/jsk_robot_common/jsk_robot_startup/scripts/smach_to_mail.py#L92

Also, since text may contain multiple base64-encoded images or filepaths, they are extracted and modified to be tweeted in succession like following tweet. https://twitter.com/pr2jsk/status/1559813371653894144

Quick Example

launch tweet.launch https://gist.github.com/iory/d70e2ee3c0749cdde593996dd98de22b Download sample image

wget https://user-images.githubusercontent.com/4690682/185071882-5d9c6bea-5d9b-4d18-9197-f7294d232131.jpg -O /tmp/pr2.jpg

After that, run tweet_sample.py https://gist.github.com/iory/3a1f02d0ffecbcb40b1212fd5d850025 for fetch kitchen demo https://twitter.com/fetch_jsk/status/1561730190098587650

tkmtnt7000 commented 2 years ago

I tested this feature with kitchen-demo. See twitter.com/fetch_jsk/status/1561611173945978880, twitter.com/fetch_jsk/status/1561611164689510400, twitter.com/fetch_jsk/status/1561611144800120832, ... etc.

k-okada commented 2 years ago

@tkmtnt7000 nice, please create PR of kitchen-demo with this description.

iory commented 2 years ago

@tkmtnt7000 Thanks. We confirmed that tweet with images is achieved by this PR. We can check the result of the kitchen demo. https://twitter.com/fetch_jsk/status/1561730190098587650

tkmtnt7000 commented 2 years ago

Thank you. I send PR to jsk-ros-pkg/jsk_robot https://github.com/jsk-ros-pkg/jsk_robot/pull/1568.

@tkmtnt7000 nice, please create PR of kitchen-demo with this description.

k-okada commented 2 years ago

ok, please add README.md, I would like to know, specially, how to display in thread. ec08a8f says Changed so that strings longer than 140 characters are displayed as a thread, but https://github.com/jsk-ros-pkg/jsk_robot/pull/1568/files#diff-dff77088a03af5caa4778675f4b8ef1da673abcf0f28c82ea7bef87abff73c5cR163-R165 publishes every description.

tkmtnt7000 commented 2 years ago

https://github.com/jsk-ros-pkg/jsk_3rdparty/commit/ec08a8fff4c76ffa36a26ef24c9986c2ad417cc3 says Changed so that strings longer than 140 characters are displayed as a thread, but jsk-ros-pkg/jsk_robot#1568 (files) publishes every description.

Sorry, I forgot pushing update of using thread.

tkmtnt7000 commented 2 years ago

86a12a0 and 6d5811e

k-okada commented 2 years ago

Sorry, I forgot pushing update of using thread.

will this work if smach does not send image? @tkmtnt7000

iory commented 2 years ago

@k-okada I added README.md. https://github.com/jsk-ros-pkg/jsk_3rdparty/blob/09d1a3cbee95282f2a8d2ae8fdb7ec5f337e67d4/rostwitter/README.md

You can tweet text only, image only, and text with images.

k-okada commented 2 years ago

will this work if smach does not send image? @tkmtnt7000

what will happen if sned

[DESCRIPTION]
[DESCRIPTION]
[IMAGE]
[DESCRIPTION]
[IMAGE]
[DESCRIPTION]

???

[DESCRIPTION]
[DESCRIPTION]
↓
[IMAGE]
[DESCRIPTION]
↓
[IMAGE]
[DESCRIPTION]

not

[DESCRIPTION]
↓
[DESCRIPTION]
↓
[IMAGE]
[DESCRIPTION]
↓
[IMAGE]
[DESCRIPTION]
iory commented 2 years ago

what will happen if sned

[DESCRIPTION]
[DESCRIPTION]
[IMAGE]
[DESCRIPTION]
[IMAGE]
[DESCRIPTION]

[DESCRIPTION]
[DESCRIPTION]
[IMAGE]
↓
[DESCRIPTION]
[IMAGE]
↓
[DESCRIPTION]

The image will serve as a tweet delimiter.

Another example.

[DESCRIPTION]
[DESCRIPTION]
[IMAGE]
[IMAGE]
[IMAGE]
[IMAGE]
[IMAGE]
[DESCRIPTION (over 140 characters)]
[DESCRIPTION]
[IMAGE]

[DESCRIPTION]
[DESCRIPTION]
[IMAGE]
[IMAGE]
[IMAGE]
[IMAGE] (Up to four images per tweet)
↓
[IMAGE]
↓
[DESCRIPTION (1)] (Split into 140 full-width characters and 280 half-width characters.)
↓
[DESCRIPTION (2)]
[DESCRIPTION]
[IMAGE]
k-okada commented 2 years ago

failing on , dialogflow_task_executive/noetic, please compete https://github.com/jsk-ros-pkg/jsk_3rdparty/pull/362 @mqcmd196

2022-09-22T03:29:07.4011432Z [dialogflow_task_executive:make] Could not find a version that matches protobuf<4.0.0dev,<5.0.0dev,>=3.15.0,>=3.20.1,>=4.21.3 (from google-api-core[grpc]==1.33.1->dialogflow==1.1.1->-r requirements.in (line 1))
2022-09-22T03:29:07.4019669Z 
2022-09-22T03:29:07.4019677Z 
2022-09-22T03:29:07.4019861Z                                                                                 
2022-09-22T03:29:07.4020591Z [dialogflow_task_executive:make] Tried: 2.0.3, 2.3.0, 2.4.1, 2.5.0, 2.6.0, 2.6.1, 3.0.0, 3.0.0, 3.1.0, 3.1.0.post1, 3.1.0.post1, 3.2.0, 3.2.0, 3.3.0, 3.4.0, 3.4.0, 3.5.0.post1, 3.5.0.post1, 3.5.1, 3.5.1, 3.5.2, 3.5.2, 3.5.2.post1, 3.5.2.post1, 3.6.0, 3.6.0, 3.6.1, 3.6.1, 3.7.0, 3.7.0, 3.7.1, 3.7.1, 3.8.0, 3.8.0, 3.9.0, 3.9.0, 3.9.1, 3.9.1, 3.9.2, 3.9.2, 3.10.0, 3.10.0, 3.11.0, 3.11.0, 3.11.1, 3.11.1, 3.11.2, 3.11.2, 3.11.2, 3.11.3, 3.11.3, 3.11.3, 3.12.0, 3.12.1, 3.12.2, 3.12.2, 3.12.2, 3.12.4, 3.12.4, 3.12.4, 3.13.0, 3.13.0, 3.13.0, 3.14.0, 3.14.0, 3.14.0, 3.15.0, 3.15.0, 3.15.0, 3.15.1, 3.15.1, 3.15.1, 3.15.2, 3.15.2, 3.15.2, 3.15.3, 3.15.3, 3.15.3, 3.15.4, 3.15.4, 3.15.4, 3.15.5, 3.15.5, 3.15.5, 3.15.6, 3.15.6, 3.15.6, 3.15.7, 3.15.7, 3.15.7, 3.15.8, 3.15.8, 3.15.8, 3.16.0, 3.16.0, 3.16.0, 3.17.0, 3.17.0, 3.17.0, 3.17.1, 3.17.1, 3.17.1, 3.17.2, 3.17.2, 3.17.2, 3.17.3, 3.17.3, 3.17.3, 3.18.0, 3.18.0, 3.18.0, 3.18.1, 3.18.1, 3.18.1, 3.18.3, 3.18.3, 3.18.3, 3.19.0, 3.19.0, 3.19.0, 3.19.1, 3.19.1, 3.19.1, 3.19.2, 3.19.2, 3.19.2, 3.19.3, 3.19.3, 3.19.3, 3.19.4, 3.19.4, 3.19.4, 3.19.5, 3.19.5, 3.19.5, 3.20.0, 3.20.0, 3.20.0, 3.20.1, 3.20.1, 3.20.1, 3.20.2, 3.20.2, 3.20.2, 4.21.0, 4.21.0, 4.21.0, 4.21.0, 4.21.1, 4.21.1, 4.21.1, 4.21.1, 4.21.2, 4.21.2, 4.21.2, 4.21.2, 4.21.3, 4.21.3, 4.21.3, 4.21.3, 4.21.4, 4.21.4, 4.21.4, 4.21.4, 4.21.5, 4.21.5, 4.21.5, 4.21.5, 4.21.6, 4.21.6, 4.21.6, 4.21.6
2022-09-22T03:29:07.4025328Z 
2022-09-22T03:29:07.4025334Z 
2022-09-22T03:29:07.4025601Z                                                                                 
2022-09-22T03:29:07.4027592Z [dialogflow_task_executive:make] Skipped pre-versions: 2.0.0b0, 3.0.0a2, 3.0.0a3, 3.0.0b1, 3.0.0b1.post1, 3.0.0b1.post2, 3.0.0b2, 3.0.0b2, 3.0.0b2.post1, 3.0.0b2.post1, 3.0.0b2.post2, 3.0.0b2.post2, 3.0.0b3, 3.0.0b4, 3.0.0b4, 3.2.0rc1, 3.2.0rc1, 3.2.0rc1.post1, 3.2.0rc1.post1, 3.2.0rc2, 3.2.0rc2, 3.7.0rc2, 3.7.0rc2, 3.7.0rc3, 3.7.0rc3, 3.8.0rc1, 3.8.0rc1, 3.9.0rc1, 3.9.0rc1, 3.10.0rc1, 3.10.0rc1, 3.11.0rc1, 3.11.0rc1, 3.11.0rc2, 3.11.0rc2, 3.12.0rc1, 3.12.0rc2, 3.13.0rc3, 3.13.0rc3, 3.13.0rc3, 3.14.0rc1, 3.14.0rc1, 3.14.0rc1, 3.14.0rc2, 3.14.0rc2, 3.14.0rc2, 3.14.0rc3, 3.14.0rc3, 3.14.0rc3, 3.15.0rc1, 3.15.0rc1, 3.15.0rc1, 3.15.0rc2, 3.15.0rc2, 3.15.0rc2, 3.16.0rc1, 3.16.0rc1, 3.16.0rc1, 3.16.0rc2, 3.16.0rc2, 3.16.0rc2, 3.17.0rc1, 3.17.0rc1, 3.17.0rc1, 3.17.0rc2, 3.17.0rc2, 3.17.0rc2, 3.18.0rc1, 3.18.0rc1, 3.18.0rc1, 3.18.0rc2, 3.18.0rc2, 3.18.0rc2, 3.19.0rc1, 3.19.0rc1, 3.19.0rc1, 3.19.0rc2, 3.19.0rc2, 3.19.0rc2, 3.20.0rc1, 3.20.0rc1, 3.20.0rc1, 3.20.0rc2, 3.20.0rc2, 3.20.0rc2, 3.20.1rc1, 3.20.1rc1, 3.20.1rc1, 4.0.0rc1, 4.0.0rc1, 4.0.0rc1, 4.0.0rc2, 4.0.0rc2, 4.0.0rc2, 4.21.0rc1, 4.21.0rc1, 4.21.0rc1, 4.21.0rc1, 4.21.0rc2, 4.21.0rc2, 4.21.0rc2, 4.21.0rc2
2022-09-22T03:29:07.4029447Z 
2022-09-22T03:29:07.4029615Z 
2022-09-22T03:29:07.4030027Z                                                                                 
2022-09-22T03:29:07.4031339Z [dialogflow_task_executive:make] There are incompatible versions in the resolved dependencies:
2022-09-22T03:29:07.4036895Z 
2022-09-22T03:29:07.4036901Z 
2022-09-22T03:29:07.4037174Z                                                                                 
2022-09-22T03:29:07.4037770Z [dialogflow_task_executive:make]   protobuf<4.0.0dev,>=3.20.1 (from google-api-core[grpc]==1.33.1->dialogflow==1.1.1->-r requirements.in (line 1))
2022-09-22T03:29:07.4042402Z 
2022-09-22T03:29:07.4042408Z 
2022-09-22T03:29:07.4045033Z                                                                                 
2022-09-22T03:29:07.4045709Z [dialogflow_task_executive:make]   protobuf<5.0.0dev,>=3.15.0 (from googleapis-common-protos==1.56.4->google-api-core[grpc]==1.33.1->dialogflow==1.1.1->-r requirements.in (line 1))
2022-09-22T03:29:07.4046396Z 
2022-09-22T03:29:07.4046548Z 
2022-09-22T03:29:07.4046652Z                                                                                 
2022-09-22T03:29:07.4047335Z [dialogflow_task_executive:make]   protobuf>=4.21.3 (from grpcio-status==1.49.1->google-api-core[grpc]==1.33.1->dialogflow==1.1.1->-r requirements.in (line 1))
mqcmd196 commented 2 years ago

Sorry, I overlooked the comment. I completed https://github.com/jsk-ros-pkg/jsk_3rdparty/pull/362

knorth55 commented 1 year ago

I make a PR to improve this PR. please check it. https://github.com/iory/jsk_3rdparty/pull/9

k-okada commented 1 year ago

@iory please cosnider merging https://github.com/iory/jsk_3rdparty/pull/9