EliasKotlyar / Xiaomi-Dafang-Hacks

4.19k stars 1k forks source link

RSTP image rotation #1237

Closed isanval closed 3 years ago

isanval commented 4 years ago

Hi @EliasKotlyar ,

First of all, nice work, thank you very much for sharing it with all of us :-)

Is there any way to rotate 90º or 270º the image? I know there is a flip option (180º), but it would be interesting also to being able to rotate 90º or 270º.

In case it is not possible, is it very hard to implement it? May you consider implement it, please?

Regards,

cwiggs commented 4 years ago

Looks like that flip option is set here: https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/blob/master/firmware_mod/bin/setconf

If you run setconf with invalid settings it shows this:

/system/sdcard/bin/setconf: invalid option -- h
Invalid Argument ?
Usage /system/sdcard/bin/setconf -g -k KEY -v VALUE
Where k to set value, g to get the value
        'f' flip mode set to
                '1' -> flip on
                '0' -> flip off
        'n' night mode set to
                '1' -> night mode on
                '0' -> night mode off
        'b' set bitrate to VALUE
        'o' OSD text set to VALUE
        'c' OSD color set VALUE to
                '0' for White
                '1' for Black
                '2' for Red
                '3' for Green
                '4' for Blue
                '5' for Cyan
                '6' for Yellow
                '7' for Purple
        'x' OSD position Y pos is set to VALUE
        's' OSD size
        'e' OSD font name (ttf)
        'p' OSD space between char is set to VALUE (can be negative)
        'w' fixed text width (0 variable, 1 fixed)
        'm' motion sensitivity (0 to 4) -1 to deactivate motion
        'z' display a circle when motion detected (-1 deactivated, use the OSD color numbers)
        'r' set detection region (shall be: x0,y0,x1,y1) the server need to be restarted to take into account the new value
        't' set tracking on/off (detection region is not taken into account anymore)
        'u' set time before launching script after no motion (to restore camera position) -1 to deactivate
        'h' set hardware volume (from mic)
        'i' set software volume percentage (X will add X44 the data, from 0 to xxx, -1 to do nothing)
        'q' set set filter number (1 or 2, 0 no filter)
        'l' set set highpass filter on/off
        'a' set set aec filter on/off
        'd' set frame rate (shall be FrmRateNum,FrmRateDen (example: 25,1 to get 25 images per second)
Example: to set osd text: /system/sdcard/bin/setconf -k o -v OSDTEXT
         to get osd text: /system/sdcard/bin/setconf -g o

So it looks like right now the only option is to flip or not, if someone knows how to update setconf we might be able to add options other than flip or not.

jmtatsch commented 4 years ago

You would need add that feature to setconf and our adapted v4l2rtspserver-master https://github.com/Dafang-Hacks/Main/tree/master/v4l2rtspserver-master. Doable but the last commits of it might be broken.

isanval commented 4 years ago

@cwiggs , yes, I already saw what you said about setconf, but as you point, there is no option for rotate the image.

I saw the setconf is in source code also: https://github.com/Dafang-Hacks/Main/blob/master/v4l2rtspserver-tools/setconf.cpp I will take a look to flip implementation... it should not be very dificult adapt it for 90º or 270º image rotation.

@jmtatsch , what do you mean with "last commits of it might be broken"?

################ EDIT ################

It seems the flip is done using line 190 in https://github.com/Dafang-Hacks/Main/blob/master/v4l2rtspserver-master/src/ImpEncoder.cpp: IMP_ISP_Tuning_SetISPVflip(IMPISP_TUNING_OPS_MODE_ENABLE); IMP_ISP_Tuning_SetISPHflip(IMPISP_TUNING_OPS_MODE_ENABLE);

This function is defined in line 910 at https://github.com/Dafang-Hacks/Main/blob/master/v4l2rtspserver-master/inc/imp/imp_isp.h, but there is no source code for that.

The code is in https://github.com/Dafang-Hacks/Main/blob/master/v4l2rtspserver-master/uclibc/libimp.so

What points me to: https://github.com/EliasKotlyar/Xiaomi-Dafang-Software/issues/18

But this link https://github.com/dim08/Ingenic-T10_20 is not working anymore.

Someone have the sourcecode for libimp library or some link for download it?

Vinestou commented 4 years ago

Could we get an option in the menu? Like 'flip'?

Cocco17 commented 4 years ago

Rotating option would be great! My camera is mounted sideways, thus I need to rotate the picture with 90° - Any new progress on this request?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Cocco17 commented 4 years ago

No chance to add that function?

gadget78 commented 4 years ago

the flip option did work few months back, but new GUI has removed the flip option... as i have mine mounted on ceiling, thus upside down

where would we configure this in manually ? is there somewhere where the variable "$FLIP" is stored ?

EDIT ... found it, its stored in /system/sdcard/config/rtspserver.conf :)

Cocco17 commented 4 years ago

Hey guys,

just FYI - I found a way to rotate the stream of the camera into HomeKit by using the Plugin "Homebridge-Camera-FFMpeg" - This plugin gives you the ability to integrate command line features, such as "rotation" (check out this link for more information: https://ostechnix.com/how-to-rotate-videos-using-ffmpeg-from-commandline/)

You just need to add this line to your config.json:

    {
        "name": "Camera FFmpeg",
        "mqtt": "localhost",
        "usermqtt": "mqtt_user",
        "passmqtt": "mqtt_password",
        "topic": "Flur/Dafang/#",
        "cameras": [
            {
                "name": "Flur",
                "motion": true,
                "doorbell": true,
                "switches": true,
                "videoConfig": {
                    "source": "-rtsp_transport tcp -i rtsp://xxx.xxx.xxx.xxx:8554/unicast",
                    "stillImageSource": "-rtsp_transport http -i rtsp://xxx.xxx.xxx.xxx:8554/unicast -vframes 1 -r 1",
                    "videoFilter": "transpose=2",
                    "maxFPS": 21,
                    "maxBitrate": 299,
                    "audio": true,
                    "vflip": false,
                    "hflip": false,
                    "debug": true
                }
            }
        ],
        "platform": "Camera-ffmpeg"
    }

Do you think there is any chance add this functionality to the Dafang Plugin?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Cocco17 commented 4 years ago

Hey guys! Any news/updates/ideas for this issue? Br and thanks in advance!

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

alkissack commented 3 years ago

Flip doesnt work with Wyze camera (NEOS)