puku0x / cvdrone

CV Drone (= OpenCV + AR.Drone)
https://github.com/puku0x/cvdrone/wiki/How-to-build
Other
202 stars 94 forks source link

Example vs2010 #1

Closed mrnic3 closed 11 years ago

mrnic3 commented 11 years ago

Hi Puku,

I compiled your example code and used your api. But I have a small issue here.

Whenever I use your api, aswell as when I build the example, the process allocates more and more memory. Around 150 kb per second...

Also the yaw value seems to sligtly increase over time....

Is that a known issue?

Also, in case you ever uncomment it, startrecord should look like this: void ARDrone::startRecord() { if (version.major == ARDRONE_VERSION_2) { sockCommand.sendf("AT_CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID); sockCommand.sendf("AT_CONFIG=%d,\"video:video_on_usb\",\"TRUE\"\r", seq++); printf("AT_CONFIG=%d,\"video:video_on_usb\",\"TRUE\"\r", seq++); Sleep(100); sockCommand.sendf("AT_CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID); sockCommand.sendf("AT_CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x83); printf("AT_CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x83); Sleep(100); } }

But your code does not seem to support changing codecs once started....

Codec needs to be changed from: H264_720P_CODEC = 0x83, to: MP4_360P_H264_720P_CODEC = 0x82,

And to stop changed back.

Regards, Mr Nice

puku0x commented 11 years ago

Hi Mr Nice,

Thank you for your bug report.

I found a memory leak in ARDrone::getVideo() function. It is fixed now. Please see ".\src\ardrone\video".

The yaw value will be correct when AR.Drone is flying.

ARDrone::startRecord() and stopRecord() are omitted. I tried above code but it didn't work.

Regards, puku

mrnic3 commented 11 years ago

In case you are interested:

the ar drone starts recording when the codec is changed to: MP4_360P_H264_720P_CODEC = 0x82,

I misspelled it in the upper example...

0x82 see below...

Problem is that codec changes to mpeg 4 from x264... but drone records...

void ARDrone::startRecord() { if (version.major == ARDRONE_VERSION_2) { sockCommand.sendf("AT_CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID); sockCommand.sendf("AT_CONFIG=%d,\"video:video_on_usb\",\"TRUE\"\r", seq++); printf("AT_CONFIG=%d,\"video:video_on_usb\",\"TRUE\"\r", seq++); Sleep(100); sockCommand.sendf("AT_CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID); sockCommand.sendf("AT_CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x82); printf("AT_CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x82); Sleep(100); } }

thanks for the fix!

Mr Nice

mrnic3 commented 11 years ago

Hi Puku,

sorry to disturb you.

You are using 0x83 (• H264_720P_CODEC : Live stream with H264 hardware encoder configured in 720p mode. No record stream.)

If you change to the codecs below and activate record_on_usb the drone will record to the usb stick.

• MP4_360P_H264_720P_CODEC : Live stream with MPEG4.2 soft encoder. Record stream with H264 hardware encoder in 720p mode. • MP4_360P_H264_360P_CODEC : Live stream with MPEG4.2 soft encoder. Record stream with H264 hardware encoder in 360p mode.

All codec values: NULL_CODEC = 0, UVLC_CODEC = 0x20, // codec_type value is used for START_CODE MJPEG_CODEC, // not used P263_CODEC, // not used P264_CODEC = 0x40, MP4_360P_CODEC = 0x80, H264_360P_CODEC = 0x81, MP4_360P_H264_720P_CODEC = 0x82, H264_720P_CODEC = 0x83, MP4_360P_SLRS_CODEC = 0x84, H264_360P_SLRS_CODEC = 0x85, H264_720P_SLRS_CODEC = 0x86, H264_AUTO_RESIZE_CODEC = 0x87, // resolution is automatically adjusted according to bitrate MP4_360P_H264_360P_CODEC = 0x88,

puku0x commented 11 years ago

Hi Mr Nice,

Thank you for the code.

I tried with MP4_360P_H264_720P_CODEC but the video was not recorded in USB key.

It seems the problem is not startRecord() function but my USB key... I will try another one.

Talking about the live stream with MPEG4, it was corrupted. In my case, a bold green line was shown under the image.

What about you ?

Regards, puku

mrnic3 commented 11 years ago

recorded video 360p 720p

Hi Puku,

I have the same issue. See the attached screenshots.

The lower part of the picture is scrambled.

And I am not able to switch between the codecs while running code.

tried ardrone.finalizeVideo(); and openVideo...

and .close() and open()

Any Ideas?

Btw I resize the other picture to 720p with this code:

IplImage *dest = cvCreateImage(cvSize(1280,720), image->depth,image->nChannels); cvResize(image, dest, CV_INTER_LINEAR); image = dest;

And I use an usb Xbox controller to fly the drone. I use CXBOXController.h etc. for it. I can send you the code for the controller,,,

On Sat, Dec 22, 2012 at 2:34 AM, puku0x notifications@github.com wrote:

Hi Mr Nice,

Thank you for the code.

I tried with MP4_360P_H264_720P_CODEC but the video was not recorded in USB key.

It seems the problem is not startRecord() function but my USB key... I will try another one.

Talking about the live stream with MPEG4, it was corrupted. In my case, a bold green line was shown under the image.

What about you ?

Regards, puku

— Reply to this email directly or view it on GitHubhttps://github.com/puku0x/cvdrone/issues/1#issuecomment-11632310.

puku0x commented 11 years ago

Hi Mr Nice,

Thank you for the screenshots.

ARDrone::finalizeVideo() should be called before changing codec to avoid decoding a wrong frame.

Like this (but I don't test it yet).

void ARDrone::startRecord(void)
{
    if (version.major == ARDRONE_VERSION_2) {
        // Finalize video
        finalizeVideo();
        // Enable video record
        sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
        sockCommand.sendf("AT*CONFIG=%d,\"video:video_on_usb\",\"TRUE\"\r", seq++);
        Sleep(100);
        // Output video with MP4_360P_H264_720P_CODEC
        sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
        sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x82);
        Sleep(100);
        // Initialize video
        initVideo();
        Sleep(500);
    }
}

I don't have a Xbox controller, but it's interesting. Please send it to addr

Cheers, puku

puku0x commented 11 years ago

Hi Mr Nice,

I confirmed that the video recording worked well. I updated the repository. Please try ".\src\samples\sample_video_record.cpp" !

Regards, puku

mrnic3 commented 11 years ago

Thanks Puku, it's chirstmas here that's why I'm late with my answer, i will have a look now.