I just whipped up a quick patch to move ahead on this. I patched the libopencv_highgui.so.2.4.13 shared library directly to change the 640x480 default to 1280x720. I have minimally tested it but it gets me what I need right now, 1280x720 opencv USB webcam RGB frames without having to install a new OpenCV.
I was working with a blindfold without source so its purely experimental. If you do experiment with this, make sure you make a backup copy of the library first. It is specific to the OpenCV4Tegra from Jetpack 3.0 on the Nvidia TX2. The patch changes constants in parts of the open() function, changing the 640 and 480 assembly movz instruction constants to 1280 and 720 in the 8 places I found them.
How to patch:
- make a copy of /usr/lib/libopencv_highgui.so.2.4.13 so you have the original
- read through, build (cc, no options) and run this C program
There is a sanity check in there to look for the expected “before” values.
#include <stdio.h>
#include <inttypes.h>
int main(int argc, char **argv)
{
typedef struct {
uint32_t offset, beforeValue, afterValue;
} Oba;
Oba v[] = {
{0x28314, 0x52803c11, 0x52805A11}, // 480 to 720 lines
{0x285d4, 0x52803c03, 0x52805A03},
{0x286d4, 0x52803c00, 0x52805A00},
{0x28764, 0x52803c02, 0x52805A02},
{0x288f4, 0x52803c0b, 0x52805A0B},
{0x289f0, 0x52803c0f, 0x52805A0F},
{0x28a74, 0x52803c1e, 0x52805A1E},
{0x28b10, 0x52803c00, 0x52805A00},
{0x28310, 0x52805010, 0x5280A010}, // 640 to 1280 lines
{0x285cc, 0x52805005, 0x5280A005},
{0x286f4, 0x52805006, 0x5280A006},
{0x28768, 0x52805001, 0x5280A001},
{0x288ec, 0x5280500a, 0x5280A00A},
{0x289e8, 0x5280500e, 0x5280A00E},
{0x28a6c, 0x52805012, 0x5280A012},
{0x28b30, 0x52805006, 0x5280A006},
};
static int numV = sizeof(v) / sizeof(Oba);
printf ("DO NOT RUN WITH THIS WITHOUT BACKING UP THE LIBRARY FIRST\n");
return(0);
FILE *f = fopen("libopencv_highgui.so.2.4.13", "r+");
for (int i = 0; i < numV; i++) {
uint32_t x;
fseek(f, v[i].offset, SEEK_SET);
fread(&x, 4, 1, f);
if (x != v[i].beforeValue)
printf("Location 0x%" PRIx32 " doesn't match unpatched expected value\n", v[i].offset);
else {
fseek(f, v[i].offset, SEEK_SET);
fwrite(&v[i].afterValue, 4, 1, f);
printf("Wrote 0x%" PRIx32 " to 0x%" PRIx32 "\n", v[i].afterValue, v[i].offset);
}
}
fclose(f);
}