C++ opencv videocapture' s cap.read() method reads different frame pixsel to opencv python videocapture cap.read() method

I have been checking and comparing frame pixels of that obtained with python cv2.imread() method and C++ cv2.imread() method. C++ and python imread() method obtained same frame pixels. But when I try to use videocapture cap.read(), C++ and python got different frame pixels for same frame. My c++ and python videoCapture objects have default object arguments. I did not use any codec in videocaptures.
I do not know why I got this result. But I checked my python and c++ code many time. Already sc++ and python code very simply.

can you help me?

Please can you post a code snippet for the python and c++ and version of opencv you are using.
Please can you try another video to rule out that it is not the video itself but the code.
Admitted this is very odd and very unlikely to be opencv lib

How do you get opencv in c++ (cmake ?) and in python (pip ?)?

hi,
I share code and ouputs.
My cmake version 3.5.1, my gcc version 5.4.0
My c++ code run on jetson tx2 ubuntu 16.04.
My Python code run on Windows 10 (python version 3.7)

---------------------------python-----------------------

import cv2


def frame_read():
    cap = cv2.VideoCapture("./test4.avi")
    i = 0
    while (cap.isOpened()):
        i = i + 1
        ret, img = cap.read()

        if img is not None:

            row, column, _ = img.shape

            for k in range(224):
                print(k, end=' ')
                for l in range(224):
                    print(str(img[k,l]) + "(" + str(l) +") ", end=' ')
                print()

        break
if __name__ == '__main__':
    frame_read()

-------------------- C++ -------------------------------
#include
#include
#include
#include
#include
#include
#include
#include
#include <opencv2/opencv.hpp>
#include “opencv2/core.hpp”
#include <opencv2/core/utility.hpp>
#include “opencv2/highgui.hpp”
#include “opencv2/imgproc.hpp”
#include “opencv2/imgproc/imgproc.hpp”
#include “opencv2/cudaimgproc.hpp”
#include “opencv2/cudaarithm.hpp”
#include “opencv2/highgui/highgui.hpp”

using namespace std;

int main(int argc, char** argv)
{
        int frame_counter = 0;
        cv::VideoWriter writer;
        cv::VideoCapture cap("../video/test4.avi");
        if(!cap.isOpened()){
            std::cout<<"video acilmadi"<<std::endl;
        }

        while(1) {
            frame_counter++;

//        cv::Mat img = cv::imread("../video/test_frame_pyton/" + std::to_string(i) + ".png", cv::IMREAD_COLOR);
//        cv::Mat img = cv::imread("../video/parsed_frame_python_avi/" + std::to_string(frame_counter) + ".png", cv::IMREAD_COLOR);
//
            cv::Mat img;
            cap >> img;
            if(img.empty())
            {
                std::cout << "Could not read the image: " << std::endl;
                return 1;
            }

//        cv::imwrite("./video/parsed_frame_c/" + std::to_string(i) + ".png", frame);
//    }

            if(frame_counter == 1) {
                for (int k = 0; k < 224; k++) {
                cout <<k<<"  ";
                    for (int l = 0; l < 224; l++) {
#include <fstream>
#include <iostream>
#include <map>
#include <sstream>
#include <vector>
#include <chrono>
#include <cmath>
#include <cassert>
#include <opencv2/opencv.hpp>
#include "opencv2/core.hpp"
#include <opencv2/core/utility.hpp>
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/cudaarithm.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace std;

int main(int argc, char** argv)
{
        int frame_counter = 0;
        cv::VideoWriter writer;
        cv::VideoCapture cap("../video/test4.avi");
        if(!cap.isOpened()){
            std::cout<<"video acilmadi"<<std::endl;
        }

        while(1) {
            frame_counter++;

//        cv::Mat img = cv::imread("../video/test_frame_pyton/" + std::to_string(i) + ".png", cv::IMREAD_COLOR);
//        cv::Mat img = cv::imread("../video/parsed_frame_python_avi/" + std::to_string(frame_counter) + ".png", cv::IMREAD_COLOR);
//
            cv::Mat img;
            cap >> img;
            if(img.empty())
            {
                std::cout << "Could not read the image: " << std::endl;
                return 1;
            }

//        cv::imwrite("./video/parsed_frame_c/" + std::to_string(i) + ".png", frame);
//    }

            if(frame_counter == 1) {
                for (int k = 0; k < 224; k++) {
                cout <<k<<"  
                    cout<<img.at<cv::Vec3b>(k, l)<<"("<<l<<") ";
                    }
                    cout << "" << endl;
                }
            }

            if(frame_counter==1){

                break;
            }
        }
        cap.release();

    return 0;
}

Please carefully examine pixel outputs of both C++ and Python

it would be better if you could post pictures as pictures, not as text.

Actually,
the code works the same for any video.
You can test it on a video you want

You means results on windows and jetson are not equal?

What’s codec name on jetson and windows 10

Yes my results on windows and jetson are not equal.
C++ and python cap.read()'s frame have different pixel values .
I haven’t used codec arguments. I used default codec for python and c++ as in shared code

please quantify precisely by how much they differ.

don’t expect everyone here to have your precise setup (windows + jetson) to replicate your issue.

Default ?
check cv version and codecs with print(cv.getBuildInformation()) and cout<< cv::getBuildInformation( )

thanks for your suggestions, I may find the reason:

why are those posts just pictures of text? why did you not post the text itself?