Skip to main content

A plot library using pure opencv.

Project description

cv-plot-python

A python implementation of the CvPlot library from PROFACTOR. I needed a fast drawing library as using matplotlib within an application is cumbersome and slow. So I searched for another opportunity using pure OpenCV and found this... So I reimplemented it in python using the Gemini Flash 2.5 Model from Google.

Usage

In this library you must basically build the whole plot yourself. You have to add the Axis, the grid and of course the actual plot. There are some basic helper methods found in cv_plot.plot. You can create a LinePlot and a ScatterPlot (with the Series class) and can show Images as well as HorizontalLines and VerticalLines. You can use this as follows:

import cv_plot.plot as cvplt
import cv2

ax = cvplt.makePlotAxes()
s = ax.create(cvplt.Series, x=[0,1,2,3,4], y=[2,3,1,5,6], lineSpec="r-") # this would be a red LinePlot, to create a green ScatterPlot just replace 'r-' with 'g.'
img = ax.render(600,400) # now you have an standard OpenCV image (which is a np.ndarray with type np.uint8)
# show it in a window
plt.show(img)

To use alpha blending you have to set the alpha value AFTER creating the Drawable, like so:

# Can also now fill a polygon
s = ax.create(cvplt.Series, x=[0,1,2,3,2,1], y=[2,3,1,5,6,-2], lineSpec="r-", fill=True)
s.alpha=0.3

You can do a little bit more in the sense of styling and setting y and x limits but thats basically it.

Legend

As I had some circular import errors to use a Legend (as it imports Axes from core) you have to import it after import cv_plot.plot as cvplt with something like:

from cv_plot.drawables.legend import Legend

Extending

You can add additionaly drawables by inheriting from cv_plot.core.Drawable. There you must especially implement the render(RawProjection) function and the getBoundingRect() function (to automatical determine the axis limits). With the RawProjection you can project points from data space into display space and reverse with unproject. The RawProjection contains an inner_rect which is the inside of the axis boundaries (and mainly the drawing area).

Notes

I removed the cv_plot.gui part as it has its flaws and also didn't work correctly in the cpp version (at least with the Qt backend I was not able to zoom into the axis). But I added the cv_plot.plot.show function to allow easy showing of the plot.

---- ORIGINAL README BELOW ----

CvPlot

Build status Build status Build Status

Motivation

Yes, another C++ plotting library. Because CvPlot is

CvPlot was developed at PROFACTOR for realtime image plotting. It comes with some basic "Drawables", including Series, Image, Axis, Grid, Titles, etc. Drawables can easily be modified, replaced and extended, using standard OpenCV drawing functions. CvPlot comes with an interactive viewer, based on cv::imshow(). The viewer can easily be integrated into any C++ GUI framework (e.g. Qt/Qml in CvPlotQt).

Warning

CvPlot is NOT and will never be a full featured plotting library. Many features are missing, but you can easily add them using custom drawables.

Documentation

Screenshots

Integration

Tutorial

Other C++ OpenCV Libraries

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opencv_cv_plot-0.5.0.tar.gz (30.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opencv_cv_plot-0.5.0-py3-none-any.whl (37.8 kB view details)

Uploaded Python 3

File details

Details for the file opencv_cv_plot-0.5.0.tar.gz.

File metadata

  • Download URL: opencv_cv_plot-0.5.0.tar.gz
  • Upload date:
  • Size: 30.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.19

File hashes

Hashes for opencv_cv_plot-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b48ecd5fd742d0b780261a4cc85af23659883915452c44de3fc3f43e70f46248
MD5 6b74ff5594538ffb1829c7bf9eca39f3
BLAKE2b-256 36a5ccc15513069efe13eee707f4863cf68ec8b8adfeae2a99919fef7fee0c6d

See more details on using hashes here.

File details

Details for the file opencv_cv_plot-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for opencv_cv_plot-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf17c4d4a29f93e41dd74ddc1ac8ac2138707725cfa4016d2e99f6928954320d
MD5 f2b184dde9876e59743a5f1a5b80758e
BLAKE2b-256 d70751acdd57fdbaa219e38a50eb76fd526f7c38a5288143a3196cab0b118a81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page