TIPS: Use cximage to convert the original image data obtained from the camera to JPG, and then send it out through DDS.

Source: Internet
Author: User

I think there is nothing betterCodeMore clearly. Click "Cuihua, upload code ".

Int videopublisher_t: publishvideo (long LW, long LH, ace_uint8 * dibdata, Long SIZE)
{
Ace_uint8 * jpgimagedata = 0;
Long jpgimagedatasize = 0;
Cximage image;
Video: framedatawriter_var DW =
Video: framedatawriter: _ narrow (this-> datawriter _. In ());
If (CORBA: is_nil (DW. In ()))
{
Ace_error_return (lm_error, "(% T | % t) narrow frame data writer/N"),-1 );
}
// Bytes alignment
Ace_uint32 bytesperline = 4 * (LW * 24 + 31)/32 );
// Convert original RGB data to image
Image. createfromarray (
(Unsigned char *) dibdata,
Lw,
LH,
24,
Bytesperline,
False );
Image. encode (jpgimagedata, jpgimagedatasize, cximage_format_jpg );
Image. set0000quality (24 );

Video: frame;
Frame. frameid = 0;
Frame. timestamp =: gettimestamp ();
Frame. DeviceID = options: instance ()-> getdeviceid ();
Frame. type = video: it_jpg;
Frame. deviceinfo = CORBA: string_dup (this-> statmsg _);
Frame. image. Length (jpgimagedatasize );
Ace_ OS: memcpy (frame. image. get_buffer (), (const void *) jpgimagedata, jpgimagedatasize );
Image. freememory (jpgimagedata );

Dds: returncode_t ret = DW-> write (frame, DDS: handle_nil );
If (Ret! = Dds: retcode_ OK)
{
Ace_error_return (lm_error, "(% T | % t) Data writer/N"),-1 );

}

return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.