Ask Your Question

Nocs's profile - activity

2020-05-04 11:57:46 -0600 received badge  Notable Question (source)
2018-11-30 09:42:05 -0600 received badge  Popular Question (source)
2016-12-15 13:25:40 -0600 received badge  Enthusiast
2016-12-14 22:19:09 -0600 commented answer Captured frame RGB to YUV and Reverse

Thanks for the code cause i couldnt find how the split Mat function works. I dont understand the way though that i will have to manage the y,u,v buffers, do i have to place them in a for loop as above and get into a plane cause sending them y,u,v as is gives me a crash cause of wrong values i send :/ If you have any good tutotial i could learn also or code to convert them the way the above code did would be much appreciated

2016-12-14 22:15:07 -0600 received badge  Supporter (source)
2016-12-14 19:02:01 -0600 commented question Captured frame RGB to YUV and Reverse

This is the part of a code not the full code, and i need 2 parts one that i will convert the VideoCapture from camera to yuv and send it as y,u,v with strides from a buffer and the second to recieve y,u,v,ystride,ustride,vstride buffer and convert it to rgb and show it in a window of imshow("Recieved Cam" img) or cvShowImage(....) for e.x. To make it more clear i need to send from sendFrame() and recieveFrame() the values they need.

2016-12-14 18:34:21 -0600 commented question Captured frame RGB to YUV and Reverse

@Tetragramm thanks for the response, i have tried this cvtColor(CamFrame, CamFrame, COLOR_BGR2YUV); but how do i get the values of y,u,v with the strides out of it ? the planes array stores and modifies the rgb to yuv values with strides in it and each one of them need to be send individually, how can i get this values from the cvtColor output Mat ?

2016-12-14 16:12:26 -0600 asked a question Captured frame RGB to YUV and Reverse

I have this code which is a bit of old but it was used to convert RGB to YUV but for me doesn't work, i am using c++ and MVS2013 and opencv to make this happen, i want to capture the RGB frame convert it to YUV and send the values of YUV array through buffer and do the oposite on the recieve as in the code below but it doesn`t convert it and have an error near the send function commented also.

Anyone with good knowledge on opencv would be nice to give me a good solution on it, anything can be changed except the functions of send and recieve which needs to get these data through buffer and i am not so expert to make it work well.

#define CLIP(X) ((X) > 255 ? 255 : (X) < 0 ? 0 : X)

// RGB -> YUV
#define RGB2Y(R, G, B) CLIP((( 66 * (R) + 129 * (G) +  25 * (B) + 128) >> 8) +  16)
#define RGB2U(R, G, B) CLIP(((-38 * (R) -  74 * (G) + 112 * (B) + 128) >> 8) + 128)
#define RGB2V(R, G, B) CLIP(((112 * (R) -  94 * (G) -  18 * (B) + 128) >> 8) + 128)

// YUV -> RGB
#define C(Y) ((Y) - 16  )
#define D(U) ((U) - 128 )
#define E(V) ((V) - 128 )

#define YUV2R(Y, U, V) CLIP((298 * C(Y) + 409 * E(V) + 128) >> 8)
#define YUV2G(Y, U, V) CLIP((298 * C(Y) - 100 * D(U) - 208 * E(V) + 128) >> 8)
#define YUV2B(Y, U, V) CLIP((298 * C(Y) + 516 * D(U) + 128) >> 8)

//////////// SEND FRAME
#define FRAME_WIDTH 640
#define FRAME_HEIGHT 480
Mat CamFrame;

VideoCapture CaptureCam(0);
CaptureCam.set(CV_CAP_PROP_FRAME_WIDTH, FRAME_WIDTH);
CaptureCam.set(CV_CAP_PROP_FRAME_HEIGHT, FRAME_HEIGHT);
if (!CaptureCam.isOpened()){
    cout << "could not open camera" << endl;
}
namedWindow("Captures Cam", CV_WINDOW_AUTOSIZE);

while (TestingCLoop){
    CaptureCam >> CamFrame;
    if (!CamFrame.empty()){
        IplImage *frame = new IplImage(CamFrame);
        int32_t strides[3] = { 1280, 640, 320 };    
        uint8_t *planes[3] = {  
            (uint8_t *)malloc(frame->height * frame->width),    
            (uint8_t *)malloc(frame->height * frame->width / 4),    
            (uint8_t *)malloc(frame->height * frame->width / 4),
        };

        int x_chroma_shift = 1;
        int y_chroma_shift = 1;

        int x, y;   
        for (y = 0; y < frame->height; ++y) {   
            for (x = 0; x < frame->width; ++x) {    
                uint8_t r = frame->imageData[(x + y * frame->width) * 3 + 0];   
                uint8_t g = frame->imageData[(x + y * frame->width) * 3 + 1];
                uint8_t b = frame->imageData[(x + y * frame->width) * 3 + 2];

                planes[0][x + y * strides[0]] = RGB2Y(r, g, b); ///////// IT HAS ERROR ON THIS "EMPTY"

                if (!(x % (1 << x_chroma_shift)) && !(y % (1 << y_chroma_shift))) { 
                    const int i = x / (1 << x_chroma_shift);
                    const int j = y / (1 << y_chroma_shift);    
                    planes[1][i + j * strides[1]] = RGB2U(r, g, b); 
                    planes[2][i + j * strides[2]] = RGB2V(r, g, b);
                }   
            }
        }
        sendFrame(frame->width, frame->height, planes[0], planes[1], planes[2]);
    }
}



////////////////////////// RECIEVE FRAME 
recieveFrame(uint16_t width, uint16_t height, uint8_t const *y, uint8_t const *u, uint8_t const *v, int32_t ystride, int32_t ustride, int32_t vstride){

    ystride = abs(ystride);
    ustride = abs(ustride);
    vstride = abs(vstride);

    uint16_t *img_data = (uint16_t *)malloc(height * width * 6);
    unsigned long int i, j;
    for (i = 0; i < height; ++i) {
        for (j = 0; j < width; ++j ...
(more)
2016-12-08 15:22:04 -0600 received badge  Self-Learner (source)
2016-12-08 15:17:20 -0600 received badge  Scholar (source)
2016-12-08 15:17:12 -0600 answered a question Linking staticlib in mvs2013 release gives external errors

The solution to this problem if anyone encounter it again is this post as LBerger very well pointed to
http://stackoverflow.com/questions/16...

You need to include the Vfw32.lib inside your project along with all the opencv static lib files and includes. The Vfw32.lib is not inside the Opencv libraries but it is in windows visual studio

The solved answered goes to LBerger ^.^ Thanks LBerger

2016-12-08 15:15:33 -0600 commented answer Linking staticlib in mvs2013 release gives external errors

Holly crap, you are right, the Vfw32.lib is in the mvs2013 and i was searching for it inside opencv :s Thanks yes that solved it

2016-12-08 11:51:55 -0600 commented answer Linking staticlib in mvs2013 release gives external errors

Thanks for the response, i have searched and i dont have any Vfw32.lib inside the opencv.2.4.13 prebuilted. I found the cap_vfw.cpp i added to the project which was in the source folder not in the build i added also the precomp.hpp which needs to be with it and again it pops the same errors exactly. Is it something with imcombatibility with my system or i am doing something wrong cause i think it has to do something with static lib since its ok with dynamic libs :/ I use the prebuild latest version 2.4.13 what else can i check after all this ?

2016-12-07 09:35:14 -0600 commented question Linking staticlib in mvs2013 release gives external errors

@LBerger. yes if i remove the VideoCapture it builds in static with Mat and all the libs included with no errors. When i enter the Videocapture cap(CV_CAP_ANY); it pops up all the 20 errors. Do i need to define or redefine anything else from higigui.hpp into my cpp file in order to work with static mode ? The problem seems to be in the highgui.lib when in static build

2016-12-06 17:42:55 -0600 commented question Linking staticlib in mvs2013 release gives external errors

I have tested also the staticlib in debug mode with the debug .libs also has the same 20 errors refering to the openv_highgui2413d.lib(cap_vfw.obj), it has something to do with the staticlib and this lib. Do i need to use included headers or any other files from opencv inside my project except the libs ?

2016-12-06 04:33:41 -0600 commented question Linking staticlib in mvs2013 release gives external errors

yes thats for sure, i havent test the debug static though, cause i need to implement it after my tests to a solution that need to be build in release mode, but i will try the debug later just to see if it has something to do with the release option instead of the debug.

2016-12-05 20:00:38 -0600 commented question Linking staticlib in mvs2013 release gives external errors

It doesn`t compile with any version i downloaded, it always pops up the same unresolved external about (cap_vfw.obj) inside the opencv_highgui2413.lib ... any suggestion ?

2016-12-05 13:09:26 -0600 commented answer Linking staticlib in mvs2013 release gives external errors

Thanks for the response i am on my way for testing it i will let you know, I tried with every possible option in the Linker options but cant make it work :/... i am downloading also the 3.1 version to check if it can work with it in static

2016-12-05 13:09:22 -0600 commented answer Linking staticlib in mvs2013 release gives external errors

Thanks for the response i am on my way for testing it i will let you know Nope, i ve tested by changing the lib order as you said and even tried other compinations but cant solve the static issue :/

2016-12-05 08:41:20 -0600 commented question Linking staticlib in mvs2013 release gives external errors

@LBerger i updated my quesion with your request. I can provide also the unresolved external on "opencv_highgui2413.lib(cap_vfw.obj)" library which functions had the errors on

2016-12-05 08:37:12 -0600 received badge  Editor (source)
2016-12-04 21:19:47 -0600 asked a question Linking staticlib in mvs2013 release gives external errors

I have multiple errors LNK2001: unresolved external symbol error "opencv_highgui2413.lib(cap_vfw.obj) when i try to use the staticlib folder instead of lib and dlls in mvs2013 windows 10 and release option in project build. The statilib i am trying to use is opencv-2.4.13.exe

  • By C/C++ linking the include directory to : D:\OpenCV\build\include
  • By Linker linking the include dependancies to : D:\OpenCV\build\x86\vc12\staticlib And using : No Incremental linking
  • By Linker input additional dependancies entering each one .lib inside the folder of staticlib without "d"
  • By C/C++ using runtime library to : Multi-Threaded(/MT)

Is there anything i do wrong or is it something else ? Windows 10 - mvs2013 - The project i create to test is only a VideoCapture webcam test

My Test project is working fine if i dont use the staticlib and use the lib with dlls but since i want a staticlib i test it with the above linkings of opencv and it has errors in every function of object opecv_highgui2413.lib

Thanks in advance for any kind of help to solve this issue

@LBerger request :

  • C/C++ command line /GS /GL /analyze- /W3 /Gy /Zc:wchar_t /I"D:\OpenCV\build\include"/Zi /Gm- /O2 /Fd"Release\vc120.pdb" /fp:precise /D "WIN32" /D "_CONSOLE" /D "_LIB" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MT /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\TestVideo.pch"

  • LINKER command line /OUT:"D:\TestVideo\Release\TestVideo.exe" /MANIFEST /LTCG /NXCOMPAT /PDB:"D:\TestVideo\Release\TestVideo.pdb" /DYNAMICBASE "opencv_calib3d2413.lib" "opencv_contrib2413.lib" "opencv_core2413.lib" "opencv_features2d2413.lib" "opencv_flann2413.lib" "opencv_gpu2413.lib" "opencv_highgui2413.lib" "opencv_imgproc2413.lib" "opencv_legacy2413.lib" "opencv_ml2413.lib" "opencv_nonfree2413.lib" "opencv_objdetect2413.lib" "opencv_ocl2413.lib" "opencv_photo2413.lib" "opencv_stitching2413.lib" "opencv_superres2413.lib" "opencv_ts2413.lib" "opencv_video2413.lib" "opencv_videostab2413.lib" "IlmImf.lib" "libjasper.lib" "libjpeg.lib" "libpng.lib" "libtiff.lib" "zlib.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /OPT:REF /SAFESEH /INCREMENTAL:NO /PGD:"D:\TestVideo\Release\TestVideo.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Release\TestVideo.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"D:\OpenCV\build\x86\vc12\staticlib" /TLBID:1

And Here is the small test which work with dynamic built of openv and not with static maby could help someone to help me out :

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace cv;
using namespace std;

int main(){

    Mat CamFrame;
    VideoCapture CaptureCam(CV_CAP_ANY);
    ..... alla others not needed cause even with VideoCapture it pops up all errors
    ..... if i remove VideoCapture no errors at all it builds in release mode and static opencv with all libs inside
    return 0; 
}

@LBerger yes it builds it without errors but it doesn`t show the image at all, it opens the window and stays with gray backroung and no image is loaded inside, the image is on the same folder with my executable so it has something to ... (more)