• Skip to primary navigation
  • Skip to main content
OpenCV

OpenCV

Open Computer Vision Library

  • Library
    • Releases
    • Platforms
    • License
  • Forum
    • OpenCV Forum (New!)
    • Askbot (Old Forum)
  • OpenCV University
    • All Courses
      • Mastering OpenCV with Python
      • Fundamentals of CV & IP
      • Deep Learning with PyTorch
      • Deep Learning with TensorFlow & Keras
      • Advanced Vision Applications with Deep Learning & Transformers
      • Mastering Generative AI for Art
    • CVDL Master Program
    • Courses [Enrolled Users]
    • For Organizations
    • Student Discount
    • CareerX
  • Free Courses
    • VLM Bootcamp NEW
    • PyTorch Bootcamp NEW
    • TensorFlow Keras Course
    • OpenCV Bootcamp
    • Python for Beginners
  • Services
  • Face Recognition
  • Contribute
    • Area Chairs
    • Membership
      • Platinum
      • Gold
    • Development Partnership
    • Course Partnership
  • Resources
    • Research Papers
    • Get Started
    • Podcast
    • Tools
      • Roboflow
    • Links
    • Official OpenCV Logos & Media Kit
    • Leadership
    • About

Android Best Practices

General Notes

  • Follow the Android Code Style Guidelines.

Debugging

  • Use Mat.toString() and Mat.dump() methods for debugging.
  • If you develop in C++, debug your code on a host. But be aware of the performance difference. We recommend to develop/debug/optimize C++ code on a host, but please check the real speed of application on a device.

Performance

Memory

Memory efficiency should be your first concern. As we all know, memory reallocations are deadly for the device accumulator, so try to avoid them.

  1. Avoid excessive memory allocations and copyings.
  2. Initialize all the matrices at the application start and reuse them later. Please note that if the matrix doesn’t have required size and depth, OpenCV will reallocate it before usage.  Simply create all the matrices with appropriate size and depth for every purpose beforehand and use them everywhere.

JNI calls

  1. Don’t use too many calls to OpenCV Java API, because JNI-calls are really expensive. For example if you want to fill your image with zeros, don’t use put method, call the Mat.setTo() instead.
  2. Be careful with OpenCV calls within loops. Better to prepare everything outside the loop and to avoid repetitive JNI-calls.

Become a Member

Stay up to date on OpenCV and Computer Vision news

Join our Newsletter  

Free Courses

  • PyTorch Bootcamp
  • TensorFlow & Keras Bootcamp
  • OpenCV Bootcamp
  • Python for Beginners
  • PyTorch Bootcamp
  • TensorFlow & Keras Bootcamp
  • OpenCV Bootcamp
  • Python for Beginners

Courses

  • Mastering OpenCV with Python
  • Fundamentals of CV & IP
  • Deep Learning with PyTorch
  • Deep Learning with TensorFlow & Keras
  • Advanced Vision Applications with Deep Learning & Transformers
  • Mastering Generative AI for Art
  • Mastering OpenCV with Python
  • Fundamentals of CV & IP
  • Deep Learning with PyTorch
  • Deep Learning with TensorFlow & Keras
  • Advanced Vision Applications with Deep Learning & Transformers
  • Mastering Generative AI for Art

Partnership

  • Intel, OpenCV’s Platinum Member
  • Gold Membership
  • Development Partnership
  • CUDA
  • ARM
  • Intel, OpenCV’s Platinum Member
  • Gold Membership
  • Development Partnership
  • CUDA
  • ARM

Resources

  • Books
  • Podcast
  • Links
  • Official OpenCV Logos & Media Kit
  • Web Stories
  • Books
  • Podcast
  • Links
  • Official OpenCV Logos & Media Kit
  • Web Stories

General Link

  • About
  • Releases
  • License
  • About
  • Releases
  • License
Copyright © 2025, OpenCV team
  • Contact Us
  • Terms and Conditions
  • Privacy Policy
  • Contact Us
  • Terms and Conditions
  • Privacy Policy

Free Courses

  • PyTorch Bootcamp
  • TensorFlow & Keras Bootcamp
  • OpenCV Bootcamp
  • Python for Beginners

Courses

  • Mastering OpenCV with Python
  • Fundamentals of CV & IP
  • Deep Learning with PyTorch
  • Deep Learning with TensorFlow & Keras
  • Advanced Vision Applications with Deep Learning & Transformers
  • Mastering Generative AI for Art

Partnership

  • Intel, OpenCV’s Platinum Member
  • Gold Membership
  • Development Partnership
  • CUDA
  • ARM

Resources

  • Books
  • Podcast
  • Links
  • Official OpenCV Logos & Media Kit
  • Web Stories

General Link

  • About
  • Releases
  • License

Copyright © 2025 , OpenCV team
Contact Us | Privacy Policy | Terms & Conditions