Recherche avancée

Médias (91)

Autres articles (73)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

Sur d’autres sites (5111)

  • Organic Traffic : What It Is and How to Increase It

    19 septembre 2023, par Erin — Analytics Tips

    Organic traffic can be a website’s most valuable source of visitors. But it can also be the hardest form of traffic to acquire. While paid ads can generate traffic almost instantly, you need to invest time and energy into growing traffic from search engines.

    And it all starts with understanding exactly what organic traffic is. 

    If you want to understand what organic traffic is, how to measure it and how to generate more of it, then this article is for you.

    What is organic traffic ?

    Organic traffic is the visitors your website receives from the unpaid results on search engines like Google, Bing and DuckDuckGo. 

    The higher your website ranks in the search engine results pages and the more search terms your website ranks for, the more organic traffic your site will receive. 

    Organic traffic is highly valued by marketers, partly because it has a much higher clickthrough rate than PPC ads. Research shows the top organic result has a 39.8% CTR compared to just 2.1% for paid ads.

    So, while you can pay to appear at the top of search engines (using a platform like Google Ads, for instance), you probably won’t receive as much traffic as you would if you were to rank organically in the same search engine.

    What other types of traffic are there ? 

    Organic traffic isn’t the only type of traffic your website can get. You can also receive traffic from the following channels :

    Direct

    People familiar with your site may visit it directly, either by entering your URL into their browser or accessing it through a bookmarked link ; both scenarios are counted as direct traffic.

    Social

    Social traffic includes visits to your website from a social media platform. For example, if someone shares a link to your website on Facebook, any user who clicks on it will be counted as social traffic. 

    Websites

    Social media isn’t the only way for someone to share a link to your website. Any time a visitor finds your website by clicking on a link on another website, it will be counted as “websites”. This is also known as referral traffic on some analytics platforms. 

    Campaign

    Campaign traffic encompasses both paid and unpaid traffic sources. Paid sources include advertising on search engines and social media (also known as PPC or pay-per-click), as well as collaborations with influencers and sponsorships. Unpaid sources, such as your organisation’s email newsletters, cross-promotions with other businesses and other similar methods, are also part of this mix. 

    In simpler terms, it’s the traffic you deliberately direct to your site, and you utilise campaign tracking URLs to measure how these efforts impact your ROI.

    A word on multi-touch attribution

    If you are interested in learning more about types of traffic to track conversions, then it’s important to understand multi-touch attribution. The truth is most customers won’t just use a single traffic channel to find your website. In reality, the modern customer journey has multiple touchpoints, and customers may first find your site through an ad and then search for more about your brand on Google before going directly to your website. 

    You are at risk of under or overestimating the effectiveness of a marketing channel without using multi-touch attribution tracking. With this marketing analytics model, you can accurately weigh the impact of every channel and allocate budgets accordingly. 

    What are the benefits of organic traffic ?

    Getting more organic traffic is a common marketing goal for many companies. And it’s not surprising why. There’s a lot to love about organic traffic. 

    For starters, it’s arguably the most cost-effective traffic your site can receive. You will still need to pay to create and distribute organic content (whether it’s a blog post or product page). You don’t need to pay for it to show up in a search engine. You continue to get value from organic traffic long after you’ve created the page, too. A good piece of organic content can receive high volumes of monthly visitors for years. That’s a stark difference from paid ads, where traffic stops as soon as you turn off the ad. 

    It also puts your website in front of a massive audience, with Google alone processing over 3.5 billion searches every day. There’s a good chance that if your target audience is looking for a solution to their problems, they start with Google. 

    Organic traffic is fantastic at building brand awareness. Usually, users aren’t searching for a specific brand or company. They are searching for informational keywords (“how to brew the perfect cup of coffee”) or unbranded transactional keywords (“best home workout machine”). In both cases, customers can use search engines to become aware of your brand. 

    Finally, organic traffic brings in high-quality leads at every marketing funnel stage. Because users are searching for informational and transactional keywords, your site can receive visits from buyers at every stage of the marketing funnel, giving you multiple chances to convert them and helping to increase the number of touch points you have.

    How to check your website’s organic traffic

    You don’t need to complete complex calculations to determine your site’s organic traffic. A web analytics solution like Matomo will accurately measure your site’s organic traffic. 

    In Matomo, on the left-hand sidebar, you can access organic traffic data by clicking Acquisition and then selecting All Channels.

    You’ll find a detailed breakdown of all traffic sources, including organic traffic, within the specified timeframe. The report is set to the current day by default, but you can view organic traffic metrics over a day, week, month, year or a date range of your choice.

    If you want to take things further, you can get a detailed view of organic visitors by creating a custom report for “Visitors from Search Engines only.” By creating a custom report with the segment “Channel Type is search”, you’ll be able to combine other metrics like average actions per visit, bounce rate, goal conversions, etc., to create a comprehensive report on your organic traffic and the behavior of these visitors.

    Matomo also lets you integrate Google, Bing and Yahoo search consoles directly into your Matomo Analytics to monitor keyword performance.

    How to increase organic traffic

    Follow these six tips if you want to increase the web traffic you get organically from search engines. 

    Create more and better content

    Here’s the reality : Most websites don’t get much traffic from Google. Only 40% of sites rank on the first page, and just 23% sit in the top three results. 

    Let’s take quality first. The best content tends to rise to the top of search engines. That’s because it gets shared more, receives more backlinks and gets more user engagement. So, if you want to appear at the top of Google results, creating mediocre content probably won’t cut it. You need to go above and beyond what is already there. 

    But you can’t just create one fantastic piece of content and expect to receive thousands of visitors. You need multiple pages targeting as many search terms as possible. The more pages search engines index, the more opportunities you have to rank. Or, to put it another way, the more shots you take, the greater your chances of scoring. 

    Use keyword research tools

    While creating great content is essential, you want to ensure that content targets the right keywords. These keywords receive a suitable amount of traffic and are easy to rank for. 

    Keyword research tools like Ahrefs of Semrush are the easiest way to find high-traffic topics to write about. Specifically, you want to aim for long-tail keywords. These are search terms that contain three or more words. Think “Nike men’s basketball shoe” rather than “basketball shoe.”

    A keyword research report for "Basketball shoe"

    As you can see, long tail keywords have a lower monthly search volume (250 vs. 1,100 using the example above) than broad terms but are much easier to rank for (14 vs. 41 Keyword Difficulty).

    A keywords research report for Nike Men's basketball shoe

    While the above tools can help you find new topics to write about, Matomo’s Search Engine Keywords Performance plugin can help highlight topics you have already covered that could be expanded.

    Use Matomo's Search Engine Keywords Performance Plugin to see which keywords visitors use t find your website

    The plugin automatically connects to APIs from all significant search engines and imports all the keywords people search for when clicking on your websites into your Matomo report. 

    If you find a cluster of keywords on the same topic that generates a lot of visitors, it may be worth creating even more content on that topic. Similarly, if there’s a topic you think you have covered but isn’t generating much traffic, you can look at revising and refreshing your existing content to try to rank higher. 

    Build high-quality backlinks

    Backlinks are arguably the most important Google ranking factor and the primary way Google assesses the authoritativeness of your site and content. Backlinks strongly and positively correlate with traffic — at least according to 67.5% of respondents in a uSERP industry survey. 

    There are plenty of ways you can create high-quality backlinks that Google loves. Strategies include :

    • Creating and promoting the best content about a given topic
    • Guest posting on high-authority websites
    • Building relationships with other websites

    Ensure you avoid building low-quality spam links at all costs — such as private blog networks (PBNs), forum and comment spam links and directory links. These links won’t help your content to rank higher, and Google may even penalise your entire site if you build them. 

    Find and fix any technical Search Engine Optimisation (SEO) issues

    Search engines like Google need to be able to quickly and accurately crawl and index your website to rank your content. Unfortunately, many sites suffer from technical issues that impede search engine bots. 

    The good news is that certain tools make these issues easy to spot. Take the Matomo SEO Web Vitals feature, for instance. This lets you track a set of core web vital metrics, including :

    • Page Speed Score
    • First Contentful Paint (FCP)
    • Final Input Delay (FID)
    • Last Contentful Paint (LCP)
    • Cumulative Layout Shift (CLS)

    Take things even further by identifying major bugs and issues with your site. Crashes and other issues that impact user experience can also hurt your SEO and organic traffic efforts — so it’s best to eliminate them as soon as they occur. 

    See which bugs cause your site to crash and how you can recreate them

    Use Matomo’s Crash Analytics feature to get precise bug location information as well as the user’s interactions that triggered, the device they were using, etc. Scheduled reporting and alerts allow you to automate this task and instantly detect bugs as soon as they occur.

    Improve your on-page SEO

    As well as fixing technical issues, you should spend time optimising specific elements of your website to improve how it ranks in search engines. 

    There are several on-page elements you should optimise :

    • Image alt tags
    • URLs
    • Headings
    • Title tags
    • Internal links

    Your goal should be to include a target keyword in each element above. For example, your URL should be something like yoursite.com/keyword.

    It’s best to err on the side of caution here. Avoid adding too many keywords to each of these elements. This is called keyword stuffing, and Google may slap your site with a penalty. 

    Track your content’s performance

    One final way to increase organic traffic is to use an analytics platform to understand what content needs improving and which pages can be removed.

    Use Matomo's heatmap to see how customers interact with your wesbite

    Use an analytics platform like Matomo to see which pages generate the most organic traffic and which lag behind. This can help you prioritise your SEO efforts while highlighting pages that add no value. These pages can be completely revamped, redirected to another page or removed if appropriate. 

    Conclusion

    Organic traffic is arguably the most valuable traffic source your site can acquire. It is essential to monitor organic traffic levels and take steps to increase your organic traffic. 

    A good analytics platform can help you do both. Matomo’s powerful, open-source web analytics solution protects your data and your users’ privacy, while providing the SEO tools you need to send your organic traffic levels soaring. 

    Start a free 21-day trial now, no credit card required.

  • Make AVI file from H264 compressed data

    6 avril 2017, par vominhtien961476

    I’m using ffmpeg libraries to create a AVI file and following the muxing.c ffmpeg example as below

    1. Allocate the output media context : avformat_alloc_output_context2
    2. Add video streams using the AV_CODEC_ID_H264 codec with below set of parameters :

      int AddVideoStream(AVStream *&video_st, AVFormatContext *&oc, AVCodec **codec, enum AVCodecID codec_id){

      AVCodecContext *c;

      /* find the encoder */
      *codec = avcodec_find_encoder(codec_id); //codec id = AV_CODEC_ID_H264
      if (!(*codec)) {
         sprintf(strError , "Could not find encoder for '%s' line %d\n", avcodec_get_name(codec_id), __LINE__);
         commonGlobal->WriteRuntimeBackupLogs(strError);
         return RS_NOT_OK;
      }

      video_st = avformat_new_stream(oc, *codec);
      if (!video_st) {
         sprintf(strError , "Could not allocate stream line %d\n", __LINE__);
         commonGlobal->WriteRuntimeBackupLogs(strError);
         return RS_NOT_OK;
      }
      video_st->id = oc->nb_streams-1;
      c = video_st->codec;

      avcodec_get_context_defaults3(c, *codec);
      c->codec_id = codec_id;

      c->bit_rate = 500*1000;
      /* Resolution must be a multiple of two. */
      c->width    = 1280;
      c->height   = 720;
      /* timebase: This is the fundamental unit of time (in seconds) in terms
      * of which frame timestamps are represented. For fixed-fps content,
      * timebase should be 1/framerate and timestamp increments should be
      * identical to 1. */
      c->time_base.den = 25*1000;
      c->time_base.num = 1000;
      c->gop_size      = 12;//(int)(av_q2d(c->time_base) / 2);    // GOP size is framerate/2
      c->pix_fmt       = STREAM_PIX_FMT;
      /* Some formats want stream headers to be separate. */
      if (oc->oformat->flags & AVFMT_GLOBALHEADER)
         c->flags |= CODEC_FLAG_GLOBAL_HEADER;

      return RS_OK;
    3. Open Video stream : open_video

      int open_video( AVFormatContext *oc, AVCodec *codec, AVStream *st ){

      int ret;
      AVCodecContext *c = st->codec;
      char strError[STR_LENGTH_256];
      /* open the codec */
      ret = avcodec_open2(c, codec, NULL);
      if (ret < 0) {
         sprintf(strError , "Could not open video codec line %d", __LINE__);
         commonGlobal->WriteRuntimeBackupLogs(strError);
         return RS_NOT_OK;
      }

      /* allocate and init a re-usable frame */
      frame = avcodec_alloc_frame();
      if (!frame) {
         sprintf(strError , "Could not allocate video frame line %d", __LINE__);
         commonGlobal->WriteRuntimeBackupLogs(strError);
         return RS_NOT_OK;
      }

      /* Allocate the encoded raw picture. */
      ret = avpicture_alloc(&dst_picture, c->pix_fmt, c->width, c->height);
      if (ret < 0) {
         sprintf(strError , "Could not allocate picture line %d", __LINE__);
         commonGlobal->WriteRuntimeBackupLogs(strError);
         return RS_NOT_OK;
      }

      /* If the output format is not YUV420P, then a temporary YUV420P
      * picture is needed too. It is then converted to the required
      * output format. */
      if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
         ret = avpicture_alloc(&src_picture, AV_PIX_FMT_YUV420P, c->width, c->height);
         if (ret < 0) {
             sprintf(strError , "Could not allocate temporary picture line %d", __LINE__);
             commonGlobal->WriteRuntimeBackupLogs(strError);
             return RS_NOT_OK;
         }
      }

      /* copy data and linesize picture pointers to frame */
      *((AVPicture *)frame) = dst_picture;
      return RS_OK;
    4. Write AVI stream header : avformat_write_header

    5. Encode video frame :avcodec_encode_video2

      Case a : The input here are BRG frames so I encode them to H264 and pass to the next step.

      Case b : The input here are H264 compressed frames (these frames captured from H264 RTP stream) so I leave this step then move to next step.

    6. Write Interleave Video frame : av_interleaved_write_frame(oc, &pkt)

      Case a : Writing the packet data encoded from step 5 correctly without error.

      Case b : I Always get error from av_interleaved_write_frame with value -22. It could be EINVAL invalid argument. So someone can tell me what is wrong ? or Some parameters I was missing here.

      int WriteVideoFrame(AVFormatContext *&oc, AVStream *&st,
      uint8_t *imageData `/*BRG data input*/`,
      int width,
      int height,
      bool isStart,
      bool isData,
      bool isCompressed,
      AVPacket* packet `/*H264 data input*/`)

      if (isCompressed == false)// For BRG data

      static struct SwsContext *sws_ctx;
      AVCodecContext *c = st->codec;

      if (isData)
      {
         if (!frame) {
             //fprintf(stderr, "Could not allocate video frame\n");
             return RS_NOT_OK;
         }
         if (isStart == true)
             frame->pts = 0;
         /* Allocate the encoded raw picture. */
         if (width != c->width || height != c->height)
         {
             if (!sws_ctx)
             {
                 sws_ctx = sws_getContext(width, height,
                     AV_PIX_FMT_BGR24, c->width, c->height,
                     AV_PIX_FMT_YUV420P, SWS_FAST_BILINEAR, 0, 0, 0);

                 if (!sws_ctx)
                 {
                     sprintf(strError, "Could not initialize the conversion context line %d\n", __LINE__);
                     commonGlobal->WriteRuntimeBackupLogs(strError);
                     return RS_NOT_OK;
                 }
             }
             uint8_t * inData[1] = { imageData }; // RGB24 have one plane
             int inLinesize[1] = { 3 * width }; // RGB stride
             sws_scale(sws_ctx, inData, inLinesize, 0, height, dst_picture.data, dst_picture.linesize);
         }
         else
             BRG24ToYUV420p(dst_picture.data, imageData, width, height); //Phong Le changed this
      }
      if (oc->oformat->flags & AVFMT_RAWPICTURE)
      {
         /* Raw video case - directly store the picture in the packet */
         AVPacket pkt;
         av_init_packet(&pkt);

         pkt.flags |= AV_PKT_FLAG_KEY;
         pkt.stream_index = st->index;
         pkt.data = dst_picture.data[0];
         pkt.size = sizeof(AVPicture);

         ret = av_interleaved_write_frame(oc, &pkt);
         av_free_packet(&pkt);
      }
      else
      {
         /* encode the image */
         AVPacket pkt;
         int got_output;

         av_init_packet(&pkt);
         pkt.data = NULL;    // packet data will be allocated by the encoder
         pkt.size = 0;
         ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
         if (ret < 0) {
             sprintf(strError, "Error encoding video frame line %d\n", __LINE__);
             commonGlobal->WriteRuntimeBackupLogs(strError);
             av_free_packet(&pkt);
             return RS_NOT_OK;
         }

         /* If size is zero, it means the image was buffered. */
         if (got_output) {
             if (c->coded_frame->key_frame)
                 pkt.flags |= AV_PKT_FLAG_KEY;

             pkt.stream_index = st->index;

             /* Write the compressed frame to the media file. */
             ret = av_interleaved_write_frame(oc, &pkt);
         }
         else
         {
             ret = 0;
         }
         av_free_packet(&pkt);
      }
      if (ret != 0)
      {
         sprintf(strError, "Error while writing video frame line %d\n", __LINE__);
         commonGlobal->WriteRuntimeBackupLogs(strError);
         return RS_NOT_OK;
      }
      frame->pts += av_rescale_q(1, st->codec->time_base, st->time_base);
      return RS_OK;

      else /H264 data/

      if (isStart == true)
         packet->pts = 0;

      else
         packet->pts += av_rescale_q(1, st->codec->time_base, st->time_base);

      ret = av_interleaved_write_frame(oc, packet);
      if (ret < 0)
      {
         sprintf(strError, "Error while writing video frame line %d\n", __LINE__);
         commonGlobal->WriteRuntimeBackupLogs(strError);
         return RS_NOT_OK;
      }

      return RS_OK;
    1. Close file.

    -> Case a : Creating AVI file successful.

    -> Case b : Fail.

    Thanks
    Tien Vo

  • issue after video rotation how fix

    2 avril 2015, par Vahagn

    I have next code for rotate video

    OpenCVFrameConverter.ToIplImage converter2 = new OpenCVFrameConverter.ToIplImage() ;

    for (int i = firstIndex; i <= lastIndex; i++) {
       long t = timestamps[i % timestamps.length] - startTime;
       if (t >= 0) {
           if (t > recorder.getTimestamp()) {
               recorder.setTimestamp(t);
           }
           Frame g = converter2.convert(rotate(converter2.convertToIplImage(images[i % images.length]),9 0));
       recorder.record(g);
       }
    }

    images[i] - Frame in JavaCV
    after in video have green lines

    UPDATE
    Convertation function

    /*
    * Copyright (C) 2015 Samuel Audet
    *
    * This file is part of JavaCV.
    *
    * JavaCV is free software: you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation, either version 2 of the License, or
    * (at your option) any later version (subject to the "Classpath" exception
    * as provided in the LICENSE.txt file that accompanied this code).
    *
    * JavaCV is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    * GNU General Public License for more details.
    *
    * You should have received a copy of the GNU General Public License
    * along with JavaCV.  If not, see /www.gnu.org/licenses/>.
    */

    package com.example.vvardanyan.ffmpeg;

    import org.bytedeco.javacpp.BytePointer;
    import org.bytedeco.javacpp.Pointer;

    import java.nio.Buffer;

    import static org.bytedeco.javacpp.opencv_core.CV_16S;
    import static org.bytedeco.javacpp.opencv_core.CV_16U;
    import static org.bytedeco.javacpp.opencv_core.CV_32F;
    import static org.bytedeco.javacpp.opencv_core.CV_32S;
    import static org.bytedeco.javacpp.opencv_core.CV_64F;
    import static org.bytedeco.javacpp.opencv_core.CV_8S;
    import static org.bytedeco.javacpp.opencv_core.CV_8U;
    import static org.bytedeco.javacpp.opencv_core.CV_MAKETYPE;
    import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_16S;
    import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_16U;
    import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_32F;
    import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_32S;
    import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_64F;
    import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_8S;
    import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_8U;
    import static org.bytedeco.javacpp.opencv_core.IplImage;
    import static org.bytedeco.javacpp.opencv_core.Mat;

    /**
    * A utility class to map data between {@link Frame} and {@link IplImage} or {@link Mat}.
    * Since this is an abstract class, one must choose between two concrete classes:
    * {@link ToIplImage} or {@link ToMat}.
    *
    * @author Samuel Audet
    */
    public abstract class OpenCVFrameConverter<f> extends FrameConverter<f> {
       IplImage img;
       Mat mat;

       public static class ToIplImage extends OpenCVFrameConverter<iplimage> {
           @Override public IplImage convert(Frame frame) { return convertToIplImage(frame); }
       }

       public static class ToMat extends OpenCVFrameConverter<mat> {
           @Override public Mat convert(Frame frame) { return convertToMat(frame); }
       }

       public static int getFrameDepth(int depth) {
           switch (depth) {
               case IPL_DEPTH_8U:  case CV_8U:  return Frame.DEPTH_UBYTE;
               case IPL_DEPTH_8S:  case CV_8S:  return Frame.DEPTH_BYTE;
               case IPL_DEPTH_16U: case CV_16U: return Frame.DEPTH_USHORT;
               case IPL_DEPTH_16S: case CV_16S: return Frame.DEPTH_SHORT;
               case IPL_DEPTH_32F: case CV_32F: return Frame.DEPTH_FLOAT;
               case IPL_DEPTH_32S: case CV_32S: return Frame.DEPTH_INT;
               case IPL_DEPTH_64F: case CV_64F: return Frame.DEPTH_DOUBLE;
               default: return -1;
           }
       }

       public static int getIplImageDepth(Frame frame) {
           switch (frame.imageDepth) {
               case Frame.DEPTH_UBYTE:  return IPL_DEPTH_8U;
               case Frame.DEPTH_BYTE:   return IPL_DEPTH_8S;
               case Frame.DEPTH_USHORT: return IPL_DEPTH_16U;
               case Frame.DEPTH_SHORT:  return IPL_DEPTH_16S;
               case Frame.DEPTH_FLOAT:  return IPL_DEPTH_32F;
               case Frame.DEPTH_INT:    return IPL_DEPTH_32S;
               case Frame.DEPTH_DOUBLE: return IPL_DEPTH_64F;
               default:  return -1;
           }
       }
       static boolean isEqual(Frame frame, IplImage img) {
           return img != null &amp;&amp; frame != null &amp;&amp; frame.image != null &amp;&amp; frame.image.length > 0
                   &amp;&amp; frame.imageWidth == img.width() &amp;&amp; frame.imageHeight == img.height()
                   &amp;&amp; frame.imageChannels == img.nChannels() &amp;&amp; getIplImageDepth(frame) == img.depth()
                   &amp;&amp; new Pointer(frame.image[0]).address() == img.imageData().address()
                   &amp;&amp; frame.imageStride * Math.abs(frame.imageDepth) / 8 == img.widthStep();
       }
       public IplImage convertToIplImage(Frame frame) {
           if (frame == null) {
               return null;
           } else if (frame.opaque instanceof IplImage) {
               return (IplImage)frame.opaque;
           } else if (!isEqual(frame, img)) {
               int depth = getIplImageDepth(frame);
               img = depth &lt; 0 ? null : IplImage.createHeader(frame.imageWidth, frame.imageHeight, depth, frame.imageChannels)
                       .imageData(new BytePointer(new Pointer(frame.image[0].position(0)))).widthStep(frame.imageStride * Math.abs(frame.imageDepth) / 8);
           }
           return img;
       }
       public Frame convert(IplImage img) {
           if (img == null) {
               return null;
           } else if (!isEqual(frame, img)) {
               frame = new Frame();
               frame.imageWidth = img.width();
               frame.imageHeight = img.height();
               frame.imageDepth = getFrameDepth(img.depth());
               frame.imageChannels = img.nChannels();
               frame.imageStride = img.widthStep() * 8 / Math.abs(frame.imageDepth);
               frame.image = new Buffer[] { img.createBuffer() };
               frame.opaque = img;
           }
           return frame;
       }

       public static int getMatDepth(Frame frame) {
           switch (frame.imageDepth) {
               case Frame.DEPTH_UBYTE:  return CV_8U;
               case Frame.DEPTH_BYTE:   return CV_8S;
               case Frame.DEPTH_USHORT: return CV_16U;
               case Frame.DEPTH_SHORT:  return CV_16S;
               case Frame.DEPTH_FLOAT:  return CV_32F;
               case Frame.DEPTH_INT:    return CV_32S;
               case Frame.DEPTH_DOUBLE: return CV_64F;
               default:  return -1;
           }
       }
       static boolean isEqual(Frame frame, Mat mat) {
           return mat != null &amp;&amp; frame != null &amp;&amp; frame.image != null &amp;&amp; frame.image.length > 0
                   &amp;&amp; frame.imageWidth == mat.cols() &amp;&amp; frame.imageHeight == mat.rows()
                   &amp;&amp; frame.imageChannels == mat.channels() &amp;&amp; getMatDepth(frame) == mat.depth()
                   &amp;&amp; new Pointer(frame.image[0]).address() == mat.data().address()
                   &amp;&amp; frame.imageStride * Math.abs(frame.imageDepth) / 8 == (int)mat.step();
       }
       public Mat convertToMat(Frame frame) {
           if (frame == null) {
               return null;
           } else if (frame.opaque instanceof Mat) {
               return (Mat)frame.opaque;
           } else if (!isEqual(frame, mat)) {
               int depth = getMatDepth(frame);
               mat = depth &lt; 0 ? null : new Mat(frame.imageHeight, frame.imageWidth, CV_MAKETYPE(depth, frame.imageChannels),
                       new Pointer(frame.image[0].position(0)), frame.imageStride * Math.abs(frame.imageDepth) / 8);
           }
           return mat;
       }
       public Frame convert(Mat mat) {
           if (mat == null) {
               return null;
           } else if (!isEqual(frame, mat)) {
               frame = new Frame();
               frame.imageWidth = mat.cols();
               frame.imageHeight = mat.rows();
               frame.imageDepth = getFrameDepth(mat.depth());
               frame.imageChannels = mat.channels();
               frame.imageStride = (int)mat.step() * 8 / Math.abs(frame.imageDepth);
               frame.image = new Buffer[] { mat.createBuffer() };
               frame.opaque = mat;
           }
           return frame;
       }
    }
    </mat></iplimage></f></f>