1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

removed C API in the following modules: photo, video, imgcodecs, videoio (#13060)

* removed C API in the following modules: photo, video, imgcodecs, videoio

* trying to fix various compile errors and warnings on Windows and Linux

* continue to fix compile errors and warnings

* continue to fix compile errors, warnings, as well as the test failures

* trying to resolve compile warnings on Android

* Update cap_dc1394_v2.cpp

fix warning from the new GCC
This commit is contained in:
Vadim Pisarevsky
2018-11-09 00:52:09 +03:00
committed by GitHub
parent 5087ff0814
commit 11eafca3e2
34 changed files with 389 additions and 1403 deletions
+1 -1
View File
@@ -47,11 +47,11 @@
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgcodecs/imgcodecs_c.h"
#include <stdlib.h>
#include <stdio.h>
+5 -3
View File
@@ -2555,8 +2555,10 @@ void DefaultViewPort::updateImage(const CvArr* arr)
}
nbChannelOriginImage = cvGetElemType(mat);
cvConvertImage(mat, image2Draw_mat, (origin != 0 ? CV_CVTIMG_FLIP : 0) + CV_CVTIMG_SWAP_RB);
CV_Assert(origin == 0);
cv::Mat src = cv::cvarrToMat(mat), dst = cv::cvarrToMat(image2Draw_mat);
cv::cvtColor(src, dst, cv::COLOR_BGR2RGB, dst.channels());
CV_Assert(dst.data == image2Draw_mat->data.ptr);
viewport()->update();
}
@@ -3002,7 +3004,7 @@ void DefaultViewPort::drawStatusBar()
if (nbChannelOriginImage==CV_8UC1)
{
//all the channel have the same value (because of cvconvertimage), so only the r channel is dsplayed
//all the channel have the same value (because of cv::cvtColor(GRAY=>RGB)), so only the r channel is dsplayed
centralWidget->myStatusBar_msg->setText(tr("<font color='black'>(x=%1, y=%2) ~ </font>")
.arg(mouseCoordinate.x())
.arg(mouseCoordinate.y())+
+12 -17
View File
@@ -41,6 +41,7 @@
//
//M*/
#include "precomp.hpp"
#include "opencv2/imgproc.hpp"
#import <TargetConditionals.h>
@@ -910,9 +911,8 @@ static NSSize constrainAspectRatio(NSSize base, NSSize constraint) {
- (void)setImageData:(CvArr *)arr {
//cout << "setImageData" << endl;
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
CvMat *arrMat, dst, stub;
arrMat = cvGetMat(arr, &stub);
cv::Mat arrMat = cv::cvarrToMat(arr);
/*CGColorSpaceRef colorspace = NULL;
CGDataProviderRef provider = NULL;
int width = cvimage->width;
@@ -933,40 +933,35 @@ static NSSize constrainAspectRatio(NSSize base, NSSize constraint) {
}*/
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:arrMat->cols
pixelsHigh:arrMat->rows
pixelsWide:arrMat.cols
pixelsHigh:arrMat.rows
bitsPerSample:8
samplesPerPixel:3
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat: kCGImageAlphaNone
bytesPerRow:((arrMat->cols * 3 + 3) & -4)
bytesPerRow:((arrMat.cols * 3 + 3) & -4)
bitsPerPixel:24];
if (bitmap) {
cvInitMatHeader(&dst, arrMat->rows, arrMat->cols, CV_8UC3, [bitmap bitmapData], [bitmap bytesPerRow]);
cvConvertImage(arrMat, &dst, CV_CVTIMG_SWAP_RB);
cv::Mat dst(arrMat.rows, arrMat.cols, CV_8UC3, [bitmap bitmapData], [bitmap bytesPerRow]);
cv::cvtColor(arrMat, dst, cv::COLOR_BGR2RGB);
}
else {
// It's not guaranteed to like the bitsPerPixel:24, but this is a lot slower so we'd rather not do it
bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:arrMat->cols
pixelsHigh:arrMat->rows
pixelsWide:arrMat.cols
pixelsHigh:arrMat.rows
bitsPerSample:8
samplesPerPixel:3
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bytesPerRow:(arrMat->cols * 4)
bytesPerRow:(arrMat.cols * 4)
bitsPerPixel:32];
uint8_t *data = [bitmap bitmapData];
cvInitMatHeader(&dst, arrMat->rows, arrMat->cols, CV_8UC3, data, (arrMat->cols * 3));
cvConvertImage(arrMat, &dst, CV_CVTIMG_SWAP_RB);
for (int i = (arrMat->rows * arrMat->cols) - 1; i >= 0; i--) {
memmove(data + i * 4, data + i * 3, 3);
data[i * 4 + 3] = 0;
}
cv::Mat dst(arrMat.rows, arrMat.cols, CV_8UC3, [bitmap bitmapData], [bitmap bytesPerRow]);
cv::cvtColor(arrMat, dst, cv::COLOR_BGR2RGBA);
}
if( image ) {
+4 -2
View File
@@ -140,8 +140,10 @@ void cvImageWidgetSetImage(CvImageWidget * widget, const CvArr *arr){
widget->original_image = cvCreateMat( mat->rows, mat->cols, CV_8UC3 );
gtk_widget_queue_resize( GTK_WIDGET( widget ) );
}
cvConvertImage( mat, widget->original_image,
(origin != 0 ? CV_CVTIMG_FLIP : 0) + CV_CVTIMG_SWAP_RB );
CV_Assert(origin == 0);
cv::Mat src = cv::cvarrToMat(arr), dst = cv::cvarrToMat(widget->original_image);
cv::cvtColor(src, dst, cv::COLOR_BGR2RGB, dst.channels());
CV_Assert(dst.data == widget->original_image->data.ptr);
if(widget->scaled_image){
cvResize( widget->original_image, widget->scaled_image, CV_INTER_AREA );
}
+21 -84
View File
@@ -1155,7 +1155,7 @@ cvShowImage( const char* name, const CvArr* arr )
void* dst_ptr = 0;
const int channels0 = 3;
int origin = 0;
CvMat stub, dst, *image;
CvMat stub, *image;
bool changed_size = false; // philipg
if( !name )
@@ -1209,9 +1209,26 @@ cvShowImage( const char* name, const CvArr* arr )
DIB_RGB_COLORS, &dst_ptr, 0, 0));
}
cvInitMatHeader( &dst, size.cy, size.cx, CV_8UC3,
dst_ptr, (size.cx * channels + 3) & -4 );
cvConvertImage( image, &dst, origin == 0 ? CV_CVTIMG_FLIP : 0 );
{
cv::Mat src = cv::cvarrToMat(image);
cv::Mat dst(size.cy, size.cx, CV_8UC3, dst_ptr, (size.cx * channels + 3) & -4);
if (src.channels() == 1)
{
cv::cvtColor(src, dst, cv::COLOR_GRAY2BGR);
cv::flip(dst, dst, 0);
}
else if (src.channels() == 4)
{
cv::cvtColor(src, dst, cv::COLOR_BGRA2BGR);
cv::flip(dst, dst, 0);
}
else
{
CV_Assert(src.channels() == 3);
cv::flip(src, dst, 0);
}
CV_Assert(dst.data == (uchar*)dst_ptr);
}
// ony resize window if needed
if (changed_size)
@@ -1223,86 +1240,6 @@ cvShowImage( const char* name, const CvArr* arr )
__END__;
}
#if 0
CV_IMPL void
cvShowImageHWND(HWND w_hWnd, const CvArr* arr)
{
CV_FUNCNAME( "cvShowImageHWND" );
__BEGIN__;
SIZE size = { 0, 0 };
int channels = 0;
void* dst_ptr = 0;
const int channels0 = 3;
int origin = 0;
CvMat stub, dst, *image;
bool changed_size = false;
BITMAPINFO tempbinfo;
HDC hdc = NULL;
if( !arr )
EXIT;
if( !w_hWnd )
EXIT;
hdc = GetDC(w_hWnd);
if( CV_IS_IMAGE_HDR( arr ) )
origin = ((IplImage*)arr)->origin;
CV_CALL( image = cvGetMat( arr, &stub ) );
if ( hdc )
{
//GetBitmapData
BITMAP bmp;
GdiFlush();
HGDIOBJ h = GetCurrentObject( hdc, OBJ_BITMAP );
if (h == NULL)
EXIT;
if (GetObject(h, sizeof(bmp), &bmp) == 0) //GetObject(): returns size of object, 0 if error
EXIT;
channels = bmp.bmBitsPixel/8;
dst_ptr = bmp.bmBits;
}
if( size.cx != image->width || size.cy != image->height || channels != channels0 )
{
changed_size = true;
uchar buffer[sizeof(BITMAPINFO) + 255*sizeof(RGBQUAD)];
BITMAPINFO* binfo = (BITMAPINFO*)buffer;
BOOL bDeleteObj = DeleteObject(GetCurrentObject(hdc, OBJ_BITMAP));
CV_Assert( FALSE != bDeleteObj );
size.cx = image->width;
size.cy = image->height;
channels = channels0;
FillBitmapInfo( binfo, size.cx, size.cy, channels*8, 1 );
SelectObject( hdc, CreateDIBSection( hdc, binfo, DIB_RGB_COLORS, &dst_ptr, 0, 0));
}
cvInitMatHeader( &dst, size.cy, size.cx, CV_8UC3, dst_ptr, (size.cx * channels + 3) & -4 );
cvConvertImage( image, &dst, origin == 0 ? CV_CVTIMG_FLIP : 0 );
// Image stretching to fit the window
RECT rect;
GetClientRect(w_hWnd, &rect);
StretchDIBits( hdc, 0, 0, rect.right, rect.bottom, 0, 0, image->width, image->height, dst_ptr, &tempbinfo, DIB_RGB_COLORS, SRCCOPY );
// ony resize window if needed
InvalidateRect(w_hWnd, 0, 0);
__END__;
}
#endif
CV_IMPL void cvResizeWindow(const char* name, int width, int height )
{
CV_FUNCNAME( "cvResizeWindow" );